Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialIgor Yamshchykov
24,397 PointsCan't add class to link method?
I've created a project on my pc, I had installed ruby, rails and all the gems correctly, everything worked fine, but I can't add a class to a link_to
<% link_to "Post a New Status", new_status_path , class: "btn" %>
could someone please help me with that ? Maybe the version of ruby is different and that is causing problems ? I've checked out ruby API and there is class: so I'm a little lost.
Html looks like so
<a href="/statuses/new">New Status</a>
I did also tried to clear cache
1 Answer
Igor Yamshchykov
24,397 PointsI figured out the problem, I'm sorry for bothering. The problem was - I misspelled the syntax.
<% link_to "Post a New Status", new_status_path , class: "btn" %>
I've put <% instead of <%=
<%= link_to "Post a New Status", new_status_path , class: "btn" %>
works fine, guess need to install some highlighting ruby code