Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamically passing ids using slim instead of erb in ruby on rails

Hi I use slim in rails instead of erb. I need to generate dynamic ids based on the id of the record passed to the view page. This is a part of my code:

 #clear_class_"#{activity.id}"
   - user = activity.user
 .row
   .col-xs-3.col-md-2.person_img
   = link_to (image_tag user.avatar.url :normal, alt: user.full_name, class: 'img img-responsive'),  user_path(user)
   ...

when I try using #clear_class_"#{activity.id}" the view is getting distorted. How can I make this division a dynamic one with my activity id appended to the division id.

like image 889
Aditya Y Avatar asked Jan 07 '23 06:01

Aditya Y


2 Answers

Another option, if you just want to use basic string interpolation, would be this:

div id="clear-class-#{activity.id}"
like image 163
jeffdill2 Avatar answered Jan 08 '23 21:01

jeffdill2


Try this instead:

div id=dom_id(activity, 'clear_class')
like image 44
eugen Avatar answered Jan 08 '23 21:01

eugen