Rails Scaffold, ActiveRecord, and table names 5

Posted by Kerry Mon, 21 May 2007 19:36:00 GMT

Looks like the Rails scaffolding doesn’t like it when your model uses a different table name from the default mapping it expects(like when accessing a legacy database model).

So if you have a model like so:

class Thing < ActiveRecord::Base
    set_table_name "some_thing"
end

Then ActiveRecord will be expecting a table called “some_thing”, however the scaffolding generator is expecting the default, which is going to be “things”(or something like that since I can’t be bothered actually generating a model called Thing).

When running your generator you’re going to end up with an error like:

error  Before updating scaffolding from new DB schema, try creating a table for your model (Thing)

Annoying as this is, you can work around it by temporarily creating the table required by the generator. Then go ahead and drop it after the generator works.

create table things ();

I’m not sure what longer term effects this causes, and if there is a better way then let me know.

Trackbacks

Use the following link to trackback from your own site:
http://blogs.divisibleprime.com/ronin/articles/trackback/870

  1. Casino 1241270293 From Casino 1241270293
    Casino 1241270293
  2. superdrupermegapuper54321 From superdrupermegapuper54321
    superdrupermegapuper54321
  3. payday loans online without fax From payday loans online without fax
    Very usefull. Thanks! payday+loans+online+without+fax
  4. 24hr sameday cash loan without paperwork or fax From 24hr sameday cash loan without paperwork or fax
    Very usefull. Thanks! 24hr+sameday+cash+loan+without+paperwork+or+fax
  5. emergency cash loans From emergency cash loans
    Very usefull. Thanks! emergency+cash+loans
  6. instant online payday loan From instant online payday loan
    Very usefull. Thanks! instant online payday loan
  7. not a payday loans with bad credit From not a payday loans with bad credit
    Very usefull. Thanks! not a payday loans with bad credit
  8. not a payday loans with bad credit From not a payday loans with bad credit
    Very usefull. Thanks! not a payday loans with bad credit
  9. missouri regulation of pay day or title loans From missouri regulation of pay day or title loans
    Very usefull. Thanks! missouri regulation of pay day or title loans
Comments

Leave a response

  1. rach 3 days later:

    by the way, koz has said they’ve fixed this in 2.0. They’ve redone the scaffolding totally apparently :)

  2. Kerry 3 days later:

    Cool

  3. Gollo 4 days later:

    In the meantime you could try http://activescaffold.com/

  4. Gollo 4 days later:

    In the meantime you could try http://activescaffold.com/

  5. Lyle over 2 years later:

    This is what I’m looking for.

Comments