production:
adapter: mysql
database: dummy_production
username: feeds
password: password
socket: /var/lib/mysql/mysql.sock
[thufir@localhost dummy]$
[thufir@localhost dummy]$
[thufir@localhost dummy]$ mysql -u feeds -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 37 to server version: 5.0.27
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
mysql>
mysql> show databases;
±-------------------+
| Database |
±-------------------+
| information_schema |
| dummy |
| dummy_development |
| feeds |
| mysql |
| test |
±-------------------+
6 rows in set (0.00 sec)
mysql> use dummy;
Reading table information for completion of table and column
names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> describe dummy;
ERROR 1146 (42S02): Table ‘dummy.dummy’ doesn’t exist
mysql> show tables;
±----------------+
| Tables_in_dummy |
±----------------+
| px_feeds |
±----------------+
1 row in set (0.00 sec)
mysql> describe px_feeds;
±------------±-------------±-----±----±--------
±---------------+
| Field | Type | Null | Key | Default |
Extra |
±------------±-------------±-----±----±--------
±---------------+
| id | int(11) | NO | PRI | NULL |
auto_increment |
| url | varchar(250) | NO | |
| |
| title | varchar(250) | NO | |
| |
| link | varchar(250) | YES | | NULL
| |
| description | varchar(250) | YES | | NULL
| |
±------------±-------------±-----±----±--------
±---------------+
5 rows in set (0.01 sec)
I’m not sure what is meant by “create a table for the model”
because the
database has a table…they mean a different table?
From your output it looks like you have a database named ‘dummy’
containing a single table named ‘px_feeds’. The scaffold generator
can automatically create a PxFeed model based on the px_feeds table,
but you’re (implicitly) telling it to look for a ‘dummies’ table to
create a Dummy model and DummiesController controller (‘dummy’ ->
‘dummies’, assuming this falls under the general pluralization rules).
Rails assumes, that the table for a model called “dummy” is called
“dummies”, the table for a “user” model would be “users” etc. - unless
you’ve configured Rails differently. That’s one of Rails’ main
priciples, convention over configuration. I’d recommend a book called
“Agile web development with Rails” - the first part walks you through
the development of a simple shop app, which will address 90% of the
problems you’ll come across eventually, the second is a great
reference when you start building your own apps (and it also includes
the basics of Ruby, so don’t worry about that). It’s definitely worth
it - and look for the 2nd edition. http://pragmaticprogrammer.com/titles/rails
From your output it looks like you have a database named ‘dummy’
containing a single table named ‘px_feeds’. The scaffold generator
can automatically create a PxFeed model based on the px_feeds table,
but you’re (implicitly) telling it to look for a ‘dummies’ table to
create a Dummy model and DummiesController controller (‘dummy’ →
‘dummies’, assuming this falls under the general pluralization rules).
-faisal
Aha, thanks. Long term I’ll have to muck with the the configuration
because the feed-on-feeds database is setup how it’s setup, ruby will
have to work around it
Rails assumes, that the table for a model called “dummy” is called
“dummies”, the table for a “user” model would be “users” etc. - unless
you’ve configured Rails differently.
[…]
Have I not done so?
[thufir@localhost dummy]$
[thufir@localhost dummy]$ ruby script/generate scaffold dummy
exists app/controllers/
exists app/helpers/
exists app/views/dummies
exists app/views/layouts/
exists test/functional/
dependency model
exists app/models/
exists test/unit/
exists test/fixtures/
identical app/models/dummy.rb
identical test/unit/dummy_test.rb
identical test/fixtures/dummies.yml
error Before updating scaffolding from new DB schema, try
creating a table for your model (Dummy)
[thufir@localhost dummy]$
[thufir@localhost dummy]$ pwd
/home/thufir/dummy
[thufir@localhost dummy]$ ll
total 116
drwxrwxr-x 6 thufir thufir 4096 May 13 04:15 app
drwxrwxr-x 2 thufir thufir 4096 May 13 04:15 components
drwxrwxr-x 3 thufir thufir 4096 May 13 05:11 config
drwxrwxr-x 2 thufir thufir 4096 May 13 04:15 db
drwxrwxr-x 2 thufir thufir 4096 May 13 04:15 doc
drwxrwxr-x 3 thufir thufir 4096 May 13 04:15 lib
drwxrwxr-x 2 thufir thufir 4096 May 13 04:15 log
drwxrwxr-x 5 thufir thufir 4096 May 13 04:15 public
-rw-rw-r-- 1 thufir thufir 307 May 13 04:15 Rakefile
-rw-rw-r-- 1 thufir thufir 8001 May 13 04:15 README
drwxrwxr-x 4 thufir thufir 4096 May 13 04:15 script
drwxrwxr-x 7 thufir thufir 4096 May 13 04:15 test
drwxrwxr-x 6 thufir thufir 4096 May 13 04:15 tmp
drwxrwxr-x 3 thufir thufir 4096 May 13 04:15 vendor
[thufir@localhost dummy]$
[thufir@localhost dummy]$ mysql -u feeds -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 32 to server version: 5.0.27
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
mysql>
mysql> use dummy;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
±----------------+
| Tables_in_dummy |
±----------------+
| dummies |
±----------------+
1 row in set (0.00 sec)
but your YAML file (and Rails convention) has “dummy_development”,
etc.
[…]
This I’m unclear on. The database should be called dummy or
dummy_development ? change the YAML to match the database or the
database to match the YAML? If the mountain won’t come to mohammed,
then…
I was thinking that ruby would automagically figure out the
*_development in keeping with its automagically figuring out dummy and
its plural dummies.