Topic: checkboxes refuse to work

So the objective here was to have a user object that has a name, password, and a boolean/tinyint that lets the program know wether or not the user is an admin. 1 means they're an admin, 0 means they're not, etc. I have authorization set up and working and everything's great, but the only users I have I put into the database manually for test purposes, because the user creation scheme isn't working because the checkbox that I use to determine admin status is consistently refusing to work. I've tried the checkbox form thing, the form_for :model thing, and a whole bunch of other stuff. Nothing works. Here's what I have now:

<h2>New User</h2>
<p>Assign a name and password to the user, and specify if they are to be granted admin powers (generally only battalion staff are admins).</p>

<%= error_messages_for 'user' %>
<table>
<% form_for :user, @user, :url => { :action => "create_user" } do |u| %>
<tr><td>Username:</td><td><%= u.text_field :name %></td></tr>
<tr><td>Password:</td><td><%= u.text_field :password %></td></tr>
<tr><td>Grant admin powers? <%= u.check_box :isAdmin %></td></tr>
</table>
<br>
<input type = "submit" value = "Create New User">
<% end %>
<br><br>
<%= link_to 'Back', :action => 'users' %>

Re: checkboxes refuse to work

It looks correct to me. The only possible thing that might cause a problem is the capital letter. Generally column names and methods are all lowercase, so I recommend renaming it to "is_admin".

Railscasts - Free Ruby on Rails Screencasts

Re: checkboxes refuse to work

ryanb wrote:

It looks correct to me. The only possible thing that might cause a problem is the capital letter. Generally column names and methods are all lowercase, so I recommend renaming it to "is_admin".

That actually worked. If the Internet didn't separate us, I'd probably kiss you right now. This has been holding back my project for days.

Re: checkboxes refuse to work

Thank God for the internet then. Unless you're a girl. wink

Railscasts - Free Ruby on Rails Screencasts