vendredi 6 janvier 2023

Can i use variables in Rails link_to method?

Can i use variable for Rails link_to helper for making different link with variables?

For example, <%= link_to users, users_path %> I have link like this,

And i'd like to change this url with variable examples

So i changed url like this, <%= link_to users, "#{examples}_path" %> This not worked because of whole string change to url.

How can i change my link_to for use this with different variable for DRY codes?

Aucun commentaire:

Enregistrer un commentaire