Reputation: 229
I have been trying to add a class to my link_to for over an hour now. No matter what I try, I get an error.
<% if user_signed_in? %>
<li>
<%= link_to('Sign out', destroy_user_session_path, :method => :delete) %>
</li>
<% else %>
<li>
<%= link_to('Sign in', new_user_session_path) %>
</li>
<% end %>
I am trying to add :class => "page-scroll btn-signin"
to both of my link_to lines.
Upvotes: 3
Views: 3203
Reputation: 229
<%= link_to 'Sign out', destroy_user_session_path, :method => :delete, :class => "page-scroll btn-signin" %>
This code works correctly.
Upvotes: 2
Reputation: 5905
<%= link_to 'Sign in', new_user_session_path, :class => "page-scroll btn-signin" %>
and
<%= link_to 'Sign out', destroy_user_session_path, :method => :delete, :class => "page-scroll btn-signin" %>
EDIT
Destructive actions should be performed as a form submission - link
use button_to
on Sign Out
.
<%= button_to "Sign out", destroy_user_session_path, :method=>:delete, :class => "page-scroll btn-signin" %>
Upvotes: 0