Aashish Kumar
Aashish Kumar

Reputation: 115

Unable to use css classes in Ruby on Rails project

I'm using a codepen frontend template in my Ruby on Rails project so now i'm unable to connect my css file with my login.html.erb, like in this code, for submit button i want to use the "submit" class which i have styled in my css file. Also the final rendered page i not stylised which brought me to the conclusion that css file is not getting connected. Please be precise on your answer as I'm a complete beginner as this is my first RoR project. Codepen Template and My Rails Project and My login.html.erb file.

<h2>Welcome back,</h2>
 <%= form_tag("/create_session", method: :get) do %>
      Username :<%= text_field_tag(:username) %><br>
      Password :<%= password_field_tag(:password) %><br>
    <%= submit_tag(:Login), class => "submit" %>
 <% end %>

I'm getting the following error:-

app/views/sessions/login.html.erb:22: syntax error, unexpected ',', expecting ')'

Upvotes: 2

Views: 131

Answers (1)

Sebasti&#225;n Palma
Sebasti&#225;n Palma

Reputation: 33481

If you want to declare a css class for the submit_tag you can do it using :class => "class_name", or better if it would be like class: "class_name".

So you could try with:

<%= submit_tag(:Login), :class => "submit" %>
<%= submit_tag 'Login', class: "submit" %> <!-- recommended way -->

Upvotes: 3

Related Questions