0

I'm working on a project where I'm trying to implement a voting system, but I'm having some trouble, I've tried creating a form with a hidden field:

       <% form_for :vote, url: votes_path do |f| %>
          <%= f.hidden_field :rating, value: '1' %></td>
          <%= form_submit_button("vote 1") %>
       <% end %>

But when I run that the submit button does not appear, I'm not really sure what I'm doing wrong.

2 Answers 2

3

form_for generates <FORM> tag, so you need to include its output with <%=:

<%= form_for :vote, url: votes_path do |f| %>
Sign up to request clarification or add additional context in comments.

Comments

0

Use this code:

   <%= form_for :vote, url: votes_path do |f| %>
      <%= f.hidden_field :rating, value: '1' %></td>
      <%= form_submit_button("vote 1") %>
   <% end %>

= is usually shows the form in view page, if you remove it then any input tag will not be displayed.

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.