Thanks Marnen. Regarding writing a migration that changes the name of
the table, for some reason I feel like this situation is going to
happen frequently and that could fill up the migrations. GIven that
I'm only a few weeks into development and I have no real data, for
some reason I feel it'd be cleaner to revert the book migration and
add one that's correct?

On Sep 20, 10:32 am, Marnen Laibow-Koser <[email protected]> wrote:
> nobosh wrote:
> > Hello, I've been building an app recently that has a model Books
>
> That should be Book.  Rails model names are singular by convention.
> Table names are plural.
>
> > that
> > is a database table
>
> No!  Models are not database tables; please don't think of them that
> way.  They *refer* to database tables, but the Ruby objects and the DB
> records and tables are not the same thing.
>
> > and linked to several models/controllers. I
> > recently learned that instead of Books it needs to be called
> > publications (just an example)...
>
> > I now want to update the database and all the mentions throughout the
> > app. Is there a simple way to do that in Rails 3. Or do I have to
> > migrate that particular table (via version?)
>
> Version?  Huh?  Just write a migration that changes the name of the
> table.
>
> Note also that you can use set_table_name to specify a different table
> name than the one Rails would expect.  Thus, you can change the class
> name or the table name without also changing the other.  I wouldn't
> advise breaking the Rails conventions unless you have a good reason to.
>
> > and manually update all
> > the references throughout the app?
>
> Yup.  Your automated tests will break when they encounter the old class
> name and let you know where to change it.
>
>
>
> > Thanks
>
> Best,
> --
> Marnen Laibow-Koserhttp://www.marnen.org
> [email protected]
> --
> Posted viahttp://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to