Hi,
rails 3.2.8
I must be missing something basic (and it's been driving me mad) because I
am trying to send one additional data attribute to my controller from a
link, but I can't seem to get it into the params received by the controller.
I have looked around and found answers, but none seem to affect my links.
I've set up a dummy app with a home page and a single link to a contacts
page - here is the code:
routes.rb
root :to => 'home#index', :as => 'home'
resource 'contacts'
Haml Home Page View
# I want to be able to display 'bar' on the contacts page
= link_to "Contacts", contacts_path, :data => {:foo => 'bar'}
The generated html link:
<a href="/contacts <http://localhost:3000/contacts>" data-foo="bar">contacts
</a>
But I don't receive the foo attribute in the params object in the show
action of ContactsController.
If I add {:method => :post} to link_to, then it routes to the create action
of the ContactsController but again, foo is missing.
= link_to "Contacts", contacts_path, {:method => :post, :data => {:foo =>
'bar'}}
generates:
<a href="/contacts <http://localhost:3000/contacts>" data-foo="bar"
data-method="post" rel="nofollow">contacts</a>
Can anyone point me in the right direction?
Thanks
Paul
--
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].
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-/YrXt6ireP7oJ.
For more options, visit https://groups.google.com/groups/opt_out.