Mostafa Hussein
Mostafa Hussein

Reputation: 11950

How to make a check box?

Hello. I am totally new to Ruby on Rails and I want to know how to make a checkbox or link_for in a Ruby on Rails application that will change the value of an attribute called admin in a table called users from false to true , to make the normal user an admin.

NOTE : I am using form_for in creating forms

Upvotes: 0

Views: 322

Answers (2)

Michael Durrant
Michael Durrant

Reputation: 96484

You probably want something like (not tested for syntax):

<%= form_for :user do |f| %>

  <%= f.input :admin %>
  <%= f.button :submit %>

<%= end %>

in your user model make sure you have:

attr :admin

Upvotes: 0

Sławosz
Sławosz

Reputation: 11687

You may want to read, it explains how to create forms: http://guides.rubyonrails.org/form_helpers.html

Upvotes: 1

Related Questions