On Wednesday, 10 October 2012 06:25:25 UTC-7, paul h wrote:
>
> Hi Norbert,
>
> Thanks for the reply, but can you elaborate a little?
>
> On Wednesday, October 10, 2012 12:01:54 PM UTC+1, Norbert Melzer wrote:
>>
>>
>> Am 10.10.2012 09:47 schrieb "paul h" <[email protected]>:
>>
>> > # I want to be able to display 'bar' on the contacts page
>> > = link_to "Contacts", contacts_path, :data => {:foo => 'bar'}
>>
>> Should be params=>.... I here if I recall correctly. 
>>
>
> Doesn't appear to be, replacing :data with :params changes the HTML link 
> as follows:
> data-foo='bar' becomes params="{:foo=>"bar"}"
>
> Changing :data to params just mashes up the html link.
>
> AFAIK the generated HTML link is correct data-foo='bar', shouldn't this be 
> accessible in the controller as part of the params hash?
>
> If I inspect the params hash, all that is there is the usual key/value 
> pairs: controller, action, (when applicable => id, method, 
> authenticity_token).
>
> How can I send an additional data attribute to the controller? Do I have 
> problem with my routes?
>
>
Data-attributes are intended for code *on* the page (JS, etc) to use - they 
don't get sent to the server unless you're doing something fancy with JS to 
send them. You'll want to pass additional parameters to the URL helper 
(contacts_path in your example) to get them in the controller.

--Matt Jones

-- 
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/-/8lG-nXoI2vYJ.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to