Adding dynamic attributes to HAML tag using helper method in rails -


so figured out way of doing this, there easier way it? want add .class after %th tag if params[:sort] == sortby, need have rest of haml in helper-method?

this helper method helper.rb file:

def yellow?(sortby,name,id)   haml_tag :th, class: "#{'hilite' if params[:sort]== sortby}"     haml_concat link_to name, movies_path(sort: sortby),{:id => id}   end end 

this haml file:

%tr   - yellow?("title","movie title","title_header")   %th rating 

have tried solution:

%tr   %th{ :class => if params[:sort] == 'sortby' 'hilite' end }     = link_to "movie title", movies_path(:sort => 'title'), :id => "title_header"   %th rating 

you can move statement: if params[:sort] == 'sortby' 'hilite' end helper. take similar answer: haml 2 spaces issue.


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -