Search code examples
ruby-on-railsrubyajaxlink-to

Rails link_to URL and HTML options with remote: true


My current link

link_to title, params.merge(:sort => column, :direction => direction, :page => nil, :search => nil), {class: css_class}

I want to add remote: true into the mix but when I encapusulate it with the params.merge (i.e. {params.merge(), remote: true} I get a syntax error. In rails I need to encaps the url options and the html options separately right?

title and css_class are both variables inside the helper method this link is in


Solution

  • Better to use:

    link_to 'title', params.merge(:sort => column, :direction => direction, :page => nil, :search => nil), {class: css_class}, :remote => true