Ar Chron wrote:
> There's no need to know  the current_user's id in the links controller's 
> new action, that just needs to manufacture an @link for the new.html.erb 
> form.
> 
> You will need it for the create action in the links controller though. 
> Something like:

You can do it a little more simply with the "build" helper, provided
there's a has/belongs_to relationship between the user and the link.

@link = current_user.links.build(params[:link])

...will automatically set the user_id field by virtue of the association.

 - Aaron


--~--~---------~--~----~------------~-------~--~----~
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