0

I am trying to create a btn (using css) that will have both an image and a text. I have the following code that works without the class, but when I am adding the class my code breaks. Is there a way to combine all of the above in link_to?

<%= link_to new_task_path do %>
   <%= image_tag("new.png"), :class => 'btn btn-info' %> New Task 
<% end %>

2 Answers 2

1

Solved with

<%= link_to image_tag("new.png") + "New Task" , new_task_path , :class => 'icon btn' %>
Sign up to request clarification or add additional context in comments.

Comments

0

add the class on tag(anchor tag)

<%= link_to new_task_path, :class => 'btn btn-info' do %>
   <%= image_tag("new.png") %> New Task 
<% end %>

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.