Rails slim form_for tag
I am having trouble getting the form to work after switching from regular ERB to slim files. Here is the shape I'm trying to render with a thin render:
= form_for @student, :url => students_path(@student), method: :post do |f|
= f.hidden_field :student_id, :value => current_user.id
= f.hidden_field :course_id, :value => group.id
= submit_tag "Join this Class!", :class => "btn btn-primary pull-right join-button"
Here is the working code in the ERB file
<%= form_for @student, :url => students_path(@student), method: :post do |f| %>
<%= f.hidden_field :student_id, :value => current_user.id %>
<%= f.hidden_field :course_id, :value => group.id %>
<%= submit_tag "+ Join", :class => "btn btn-primary pull-right join-button" %>
<% end %>
This is the error I am currently getting:
undefined local variable or method `f'
+3
source to share
1 answer
Most of the problems with slim are indentation, try this (two spaces after form_for
):
= form_for @student, :url => students_path(@student), method: :post do |f|
= f.hidden_field :student_id, :value => current_user.id
= f.hidden_field :course_id, :value => group.id
= submit_tag "Join this Class!", :class => "btn btn-primary pull-right join-button"
+6
source to share