Hi Ray,
This is not a support channel. Please redirect your question to
http://groups.google.com/group/rubyonrails-talk group.
Best.
On Jan 15, 2008 3:42 PM, ray <rayquezada@gmail.com>
wrote:>
> 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.
> >
>
--
Cheers!
- Pratik
http://m.onkey.org
--~--~---------~--~----~------------~-------~--~----~
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 rubyonrails-core@googlegroups.com
To unsubscribe from this group, send email to
rubyonrails-core-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---