Rails Learner wrote:
> Hi Marnen,
>
> How can I pass the the whole object in link_to?
You can't.
>
> For instance, if I have a child object with first_name and last_name as
> attributes, then I need to pass the child object as a hash.
No. Pass them as two separate parameters (as I guess you're currently
doing), munge them together into one string (not recommended), or pass
an object ID if you can query the DB for it.
>
> Right now, what is working for me is this:
> <%= link_to 'Create PDF', { :controller => 'children', :action =>
> 'show', :format => :pdf, :first_name => @child.first_name, :last_name =>
> @child.last_name } %>
>
> And, I want to do something like this (but it's not working):
> <%= link_to 'Create PDF', { :controller => 'children', :action =>
> 'show', :format => :pdf, :child => @child } %>
--
Posted via http://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.