I need some help undersatnding the proper way to save (if possible)
using the create() method. I need an example to try to explain.
Say for example, I have a table called projects with id, name, and
status_id as attributes along with another table called statuses with
id, name
My Project model will contain a "belongs_to :status" and Status model
will contain a "has_many :projects".
Status table can contain ("active", "scheduled", "inactive") along
with their respective ids.
I'm trying to figure out the proper way for, say, creating a new
project model using new() or create() with an 'active' id.
So which is right and what's the difference between these?
p = Project.new(:name => "blah", :status_id =>
Status.find_by_name("active").id)
or is it
p = Project.new(:name => "blah", :status_id =>
Status.find_by_name("active"))
or is it
p = Project.new(:name => "blah", :status =>
Status.find_by_name("active").id)
or is it
p = Project.new(:name => "blah", :status =>
Status.find_by_name("active"))
Any help would be greatly appreciated. Thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Core" 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-core?hl=en
-~----------~----~----~----~------~----~------~--~---