1

I wanted to add an image with text inside my link_to so I wrote this piece of code that is working fine :

<%=link_to image_tag('fleche_droite.svg') + "Ajouter un joueur à la liste", invite_player_path(@tournament), class: "btn btn-success", id: "convocation-submit" %>

the problem is that I need to add a specific class to my image to give it the right size. How can I do that within the rails helper ?

2 Answers 2

3

Use block to define content of your link, inside block add image_tag with class

<%=link_to invite_player_path(@tournament), class: "btn btn-success", id: "convocation-submit" do %>
   <%= image_tag('fleche_droite.svg', class: 'your-class-name') %>
<% end %>

See also link_to helper

Sign up to request clarification or add additional context in comments.

Comments

1

Try this:

<%=link_to image_tag('fleche_droite.svg', class: 'my_class') + "Ajouter un joueur à la liste", invite_player_path(@tournament), class: "btn btn-success", id: "convocation-submit" %>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.