Hey guys, I''m trying to have a simple webform in my administration section to add a user. I have the text_fields for adding the user''s name, password, and password confirmation, but cannot seem to figure out the checkbox. I want it to be a single checkbox, that if clicked, will set the database column "access" to be "admin" and if its unchecked, set it to be "user". This is what I have so far but nothing is rendering just because of the check_box line. <% form_for :user do |form| %> <p> <label for "user_name">Name:</label> <%= form.text_field :name %> </p> <p> <label for="user_password">Password:</label> <%= form.password_field :password %> </p> <p> <label for="user_password_confirmation">Confirm:</label> <%= form.password_field :password_confirmation %> </p> <p> <label for="user_access">Access:</label> <%= form.check_box :access, "admin", "user" %> </p> <%= submit_tag "Add User", :class => "submit" %> <% end %> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
A quick glance at the api for check_box shows this:
check_box("puppy", "gooddog", {}, "yes",
"no")
<input type="checkbox" id="puppy_gooddog"
name="puppy[gooddog]"
value="yes" />
<input name="puppy[gooddog]" type="hidden"
value="no" />
Your code shows
<%= form.check_box :access, "admin", "user" %>
It looks like you left a parameter out, which is gonna cause problems.
Try
<%= form.check_box :access, {}, "admin", "user" %>
Note that the 2nd parameter is an empty hash... you''d use that to
specify
HTML options like :class=>"my_css_class" and other stuff.
Let me know if that helps.
On 4/16/07, AbsolutZero
<absolut0music-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:>
>
> Hey guys,
>
> I''m trying to have a simple webform in my administration section
to
> add a user. I have the text_fields for adding the user''s name,
> password, and password confirmation, but cannot seem to figure out the
> checkbox. I want it to be a single checkbox, that if clicked, will set
> the database column "access" to be "admin" and if its
unchecked, set
> it to be "user". This is what I have so far but nothing is
rendering
> just because of the check_box line.
>
> <% form_for :user do |form| %>
> <p>
> <label for
"user_name">Name:</label>
> <%= form.text_field :name %>
> </p>
> <p>
> <label
for="user_password">Password:</label>
> <%= form.password_field :password %>
> </p>
> <p>
> <label for="user_password_confirmatio
> n">Confirm:</label>
> <%= form.password_field :password_confirmation
%>
> </p>
>
> <p>
> <label
for="user_access">Access:</label>
> <%= form.check_box :access, "admin",
"user" %>
> </p>
>
> <%= submit_tag "Add User", :class =>
"submit" %>
>
> <% end %>
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Thank you so much for the help, I appreciate it.
I tried that alteration, but I received this error when trying to
access the page:
------------------------------------------------------------------------------------------------------
undefined method `access'' for #<User:0x49b0fd8>
Extracted source (around line #22):
19:
20: <p>
21: <label for="user_access">Access:</label>
22: <%= form.check_box :access, {}, "admin", "user"
%>
23: </p>
24:
25: <%= submit_tag "Add User", :class => "submit"
%>
------------------------------------------------------------------------------------------------------
It seems to think that :access is a method... its actually the name of
the column in the database. Is that wrong to put there? Do I need a
method there that assigns the database the value?
On Apr 16, 2:55 pm, "Brian Hogan"
<bpho...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> A quick glance at the api for check_box shows this:
>
> check_box("puppy", "gooddog", {}, "yes",
"no")
>
> <input type="checkbox" id="puppy_gooddog"
name="puppy[gooddog]"
> value="yes" />
> <input name="puppy[gooddog]" type="hidden"
value="no" />
>
> Your code shows
>
> <%= form.check_box :access, "admin", "user" %>
>
> It looks like you left a parameter out, which is gonna cause problems.
>
> Try
>
> <%= form.check_box :access, {}, "admin", "user"
%>
>
> Note that the 2nd parameter is an empty hash... you''d use that to
specify
> HTML options like :class=>"my_css_class" and other stuff.
>
> Let me know if that helps.
>
> On 4/16/07, AbsolutZero
<absolut0mu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
>
>
> > Hey guys,
>
> > I''m trying to have a simple webform in my administration
section to
> > add a user. I have the text_fields for adding the user''s
name,
> > password, and password confirmation, but cannot seem to figure out the
> > checkbox. I want it to be a single checkbox, that if clicked, will set
> > the database column "access" to be "admin" and if
its unchecked, set
> > it to be "user". This is what I have so far but nothing is
rendering
> > just because of the check_box line.
>
> > <% form_for :user do |form| %>
> > <p>
> > <label for
"user_name">Name:</label>
> > <%= form.text_field :name %>
> > </p>
> > <p>
> > <label
for="user_password">Password:</label>
> > <%= form.password_field :password %>
> > </p>
> > <p>
> > <label for="user_password_confirmatio
> > n">Confirm:</label>
> > <%= form.password_field
:password_confirmation %>
> > </p>
>
> > <p>
> > <label
for="user_access">Access:</label>
> > <%= form.check_box :access, "admin",
"user" %>
> > </p>
>
> > <%= submit_tag "Add User", :class =>
"submit" %>
>
> > <% end %>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Thank you so much for the help, I appreciate it.
I tried that alteration, but I received this error when trying to
access the page:
------------------------------------------------------------------------------------------------------
undefined method `access'' for #<User:0x49b0fd8>
Extracted source (around line #22):
19:
20: <p>
21: <label for="user_access">Access:</label>
22: <%= form.check_box :access, {}, "admin", "user"
%>
23: </p>
24:
25: <%= submit_tag "Add User", :class => "submit"
%>
------------------------------------------------------------------------------------------------------
It seems to think that :access is a method... its actually the name of
the column in the database. Is that wrong to put there? Do I need a
method there that assigns the database the value?
On Apr 16, 2:55 pm, "Brian Hogan"
<bpho...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> A quick glance at the api for check_box shows this:
>
> check_box("puppy", "gooddog", {}, "yes",
"no")
>
> <input type="checkbox" id="puppy_gooddog"
name="puppy[gooddog]"
> value="yes" />
> <input name="puppy[gooddog]" type="hidden"
value="no" />
>
> Your code shows
>
> <%= form.check_box :access, "admin", "user" %>
>
> It looks like you left a parameter out, which is gonna cause problems.
>
> Try
>
> <%= form.check_box :access, {}, "admin", "user"
%>
>
> Note that the 2nd parameter is an empty hash... you''d use that to
specify
> HTML options like :class=>"my_css_class" and other stuff.
>
> Let me know if that helps.
>
> On 4/16/07, AbsolutZero
<absolut0mu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
>
>
> > Hey guys,
>
> > I''m trying to have a simple webform in my administration
section to
> > add a user. I have the text_fields for adding the user''s
name,
> > password, and password confirmation, but cannot seem to figure out the
> > checkbox. I want it to be a single checkbox, that if clicked, will set
> > the database column "access" to be "admin" and if
its unchecked, set
> > it to be "user". This is what I have so far but nothing is
rendering
> > just because of the check_box line.
>
> > <% form_for :user do |form| %>
> > <p>
> > <label for
"user_name">Name:</label>
> > <%= form.text_field :name %>
> > </p>
> > <p>
> > <label
for="user_password">Password:</label>
> > <%= form.password_field :password %>
> > </p>
> > <p>
> > <label for="user_password_confirmatio
> > n">Confirm:</label>
> > <%= form.password_field
:password_confirmation %>
> > </p>
>
> > <p>
> > <label
for="user_access">Access:</label>
> > <%= form.check_box :access, "admin",
"user" %>
> > </p>
>
> > <%= submit_tag "Add User", :class =>
"submit" %>
>
> > <% end %>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Does the ''users'' table have a field called ''access'' On 4/16/07, AbsolutZero <absolut0music-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Thank you so much for the help, I appreciate it. > > I tried that alteration, but I received this error when trying to > access the page: > > > ------------------------------------------------------------------------------------------------------ > undefined method `access'' for #<User:0x49b0fd8> > > Extracted source (around line #22): > > 19: > 20: <p> > 21: <label for="user_access">Access:</label> > 22: <%= form.check_box :access, {}, "admin", "user" %> > 23: </p> > 24: > 25: <%= submit_tag "Add User", :class => "submit" %> > > ------------------------------------------------------------------------------------------------------ > > It seems to think that :access is a method... its actually the name of > the column in the database. Is that wrong to put there? Do I need a > method there that assigns the database the value? > > > On Apr 16, 2:55 pm, "Brian Hogan" <bpho...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > A quick glance at the api for check_box shows this: > > > > check_box("puppy", "gooddog", {}, "yes", "no") > > > > <input type="checkbox" id="puppy_gooddog" name="puppy[gooddog]" > > value="yes" /> > > <input name="puppy[gooddog]" type="hidden" value="no" /> > > > > Your code shows > > > > <%= form.check_box :access, "admin", "user" %> > > > > It looks like you left a parameter out, which is gonna cause problems. > > > > Try > > > > <%= form.check_box :access, {}, "admin", "user" %> > > > > Note that the 2nd parameter is an empty hash... you''d use that to > specify > > HTML options like :class=>"my_css_class" and other stuff. > > > > Let me know if that helps. > > > > On 4/16/07, AbsolutZero <absolut0mu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > Hey guys, > > > > > I''m trying to have a simple webform in my administration section to > > > add a user. I have the text_fields for adding the user''s name, > > > password, and password confirmation, but cannot seem to figure out the > > > checkbox. I want it to be a single checkbox, that if clicked, will set > > > the database column "access" to be "admin" and if its unchecked, set > > > it to be "user". This is what I have so far but nothing is rendering > > > just because of the check_box line. > > > > > <% form_for :user do |form| %> > > > <p> > > > <label for "user_name">Name:</label> > > > <%= form.text_field :name %> > > > </p> > > > <p> > > > <label for="user_password">Password:</label> > > > <%= form.password_field :password %> > > > </p> > > > <p> > > > <label for="user_password_confirmatio > > > n">Confirm:</label> > > > <%= form.password_field :password_confirmation > %> > > > </p> > > > > > <p> > > > <label for="user_access">Access:</label> > > > <%= form.check_box :access, "admin", "user" %> > > > </p> > > > > > <%= submit_tag "Add User", :class => "submit" %> > > > > > <% end %> > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Its supposed to... I say that because my original table did not
contain that field, but I added it with this migration:
------------------------------------------------------------------------------------------------------
class UserAccess < ActiveRecord::Migration
def self.up
add_column :users, :access, :string, :default => "user"
end
def self.down
remove_column :users, :access
end
end
------------------------------------------------------------------------------------------------------
I executed "rake db:migrate" but its still not showing up.. Maybe my
problem was due to my migration not editing the table? Does it matter
that there is already data in the table?
On Apr 16, 4:43 pm, "Brian Hogan"
<bpho...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Does the ''users'' table have a field called
''access''
>
> On 4/16/07, AbsolutZero
<absolut0mu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
>
>
> > Thank you so much for the help, I appreciate it.
>
> > I tried that alteration, but I received this error when trying to
> > access the page:
>
> >
------------------------------------------------------------------------------------------------------
> > undefined method `access'' for #<User:0x49b0fd8>
>
> > Extracted source (around line #22):
>
> > 19:
> > 20: <p>
> > 21: <label
for="user_access">Access:</label>
> > 22: <%= form.check_box :access, {},
"admin", "user" %>
> > 23: </p>
> > 24:
> > 25: <%= submit_tag "Add User", :class =>
"submit" %>
>
> >
------------------------------------------------------------------------------------------------------
>
> > It seems to think that :access is a method... its actually the name of
> > the column in the database. Is that wrong to put there? Do I need a
> > method there that assigns the database the value?
>
> > On Apr 16, 2:55 pm, "Brian Hogan"
<bpho...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> > > A quick glance at the api for check_box shows this:
>
> > > check_box("puppy", "gooddog", {},
"yes", "no")
>
> > > <input type="checkbox"
id="puppy_gooddog" name="puppy[gooddog]"
> > > value="yes" />
> > > <input name="puppy[gooddog]"
type="hidden" value="no" />
>
> > > Your code shows
>
> > > <%= form.check_box :access, "admin",
"user" %>
>
> > > It looks like you left a parameter out, which is gonna cause
problems.
>
> > > Try
>
> > > <%= form.check_box :access, {}, "admin",
"user" %>
>
> > > Note that the 2nd parameter is an empty hash... you''d
use that to
> > specify
> > > HTML options like :class=>"my_css_class" and other
stuff.
>
> > > Let me know if that helps.
>
> > > On 4/16/07, AbsolutZero
<absolut0mu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > > > Hey guys,
>
> > > > I''m trying to have a simple webform in my
administration section to
> > > > add a user. I have the text_fields for adding the
user''s name,
> > > > password, and password confirmation, but cannot seem to
figure out the
> > > > checkbox. I want it to be a single checkbox, that if
clicked, will set
> > > > the database column "access" to be
"admin" and if its unchecked, set
> > > > it to be "user". This is what I have so far but
nothing is rendering
> > > > just because of the check_box line.
>
> > > > <% form_for :user do |form| %>
> > > > <p>
> > > > <label for
"user_name">Name:</label>
> > > > <%= form.text_field :name %>
> > > > </p>
> > > > <p>
> > > > <label
for="user_password">Password:</label>
> > > > <%= form.password_field :password
%>
> > > > </p>
> > > > <p>
> > > > <label
for="user_password_confirmatio
> > > > n">Confirm:</label>
> > > > <%= form.password_field
:password_confirmation
> > %>
> > > > </p>
>
> > > > <p>
> > > > <label
for="user_access">Access:</label>
> > > > <%= form.check_box :access,
"admin", "user" %>
> > > > </p>
>
> > > > <%= submit_tag "Add User",
:class => "submit" %>
>
> > > > <% end %>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
No... it shouldn''t matter. I''d open up the db and make sure the field is there. Then restart the web server (just in case it didn''t pick up the db change). The code you have should work.... :access should be the method on the object bound to the form (user). If it''s burping at you, it''s probably that the field isn''t there. On 4/16/07, AbsolutZero <absolut0music-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Its supposed to... I say that because my original table did not > contain that field, but I added it with this migration: > > > ------------------------------------------------------------------------------------------------------ > class UserAccess < ActiveRecord::Migration > def self.up > add_column :users, :access, :string, :default => "user" > end > > def self.down > remove_column :users, :access > end > end > > > ------------------------------------------------------------------------------------------------------ > > I executed "rake db:migrate" but its still not showing up.. Maybe my > problem was due to my migration not editing the table? Does it matter > that there is already data in the table? > > > On Apr 16, 4:43 pm, "Brian Hogan" <bpho...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Does the ''users'' table have a field called ''access'' > > > > On 4/16/07, AbsolutZero <absolut0mu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > Thank you so much for the help, I appreciate it. > > > > > I tried that alteration, but I received this error when trying to > > > access the page: > > > > > > ------------------------------------------------------------------------------------------------------ > > > undefined method `access'' for #<User:0x49b0fd8> > > > > > Extracted source (around line #22): > > > > > 19: > > > 20: <p> > > > 21: <label for="user_access">Access:</label> > > > 22: <%= form.check_box :access, {}, "admin", "user" %> > > > 23: </p> > > > 24: > > > 25: <%= submit_tag "Add User", :class => "submit" %> > > > > > > ------------------------------------------------------------------------------------------------------ > > > > > It seems to think that :access is a method... its actually the name of > > > the column in the database. Is that wrong to put there? Do I need a > > > method there that assigns the database the value? > > > > > On Apr 16, 2:55 pm, "Brian Hogan" <bpho...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > A quick glance at the api for check_box shows this: > > > > > > check_box("puppy", "gooddog", {}, "yes", "no") > > > > > > <input type="checkbox" id="puppy_gooddog" name="puppy[gooddog]" > > > > value="yes" /> > > > > <input name="puppy[gooddog]" type="hidden" value="no" /> > > > > > > Your code shows > > > > > > <%= form.check_box :access, "admin", "user" %> > > > > > > It looks like you left a parameter out, which is gonna cause > problems. > > > > > > Try > > > > > > <%= form.check_box :access, {}, "admin", "user" %> > > > > > > Note that the 2nd parameter is an empty hash... you''d use that to > > > specify > > > > HTML options like :class=>"my_css_class" and other stuff. > > > > > > Let me know if that helps. > > > > > > On 4/16/07, AbsolutZero <absolut0mu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > Hey guys, > > > > > > > I''m trying to have a simple webform in my administration section > to > > > > > add a user. I have the text_fields for adding the user''s name, > > > > > password, and password confirmation, but cannot seem to figure out > the > > > > > checkbox. I want it to be a single checkbox, that if clicked, will > set > > > > > the database column "access" to be "admin" and if its unchecked, > set > > > > > it to be "user". This is what I have so far but nothing is > rendering > > > > > just because of the check_box line. > > > > > > > <% form_for :user do |form| %> > > > > > <p> > > > > > <label for "user_name">Name:</label> > > > > > <%= form.text_field :name %> > > > > > </p> > > > > > <p> > > > > > <label > for="user_password">Password:</label> > > > > > <%= form.password_field :password %> > > > > > </p> > > > > > <p> > > > > > <label for="user_password_confirmatio > > > > > n">Confirm:</label> > > > > > <%= form.password_field:password_confirmation > > > %> > > > > > </p> > > > > > > > <p> > > > > > <label for="user_access">Access:</label> > > > > > <%= form.check_box :access, "admin", "user" %> > > > > > </p> > > > > > > > <%= submit_tag "Add User", :class => "submit" %> > > > > > > > <% end %> > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---