Hi, I''m creating a rails app using omniauth 1.0.1 on Rails 3.1.3 and ruby 1.9.2 I''m having trouble adding a select field that populates from a class constant in my user model. Here''s my model: class User < ActiveRecord::Base ROLES = ["Customer","Service Supplier"] has_many :leads validates_presence_of :role def self.from_omniauth(auth) ... end def self.create_with_omniauth(auth) ... end end Here''s a snippet of my view from identities/new.html.erb: <%= form_tag "/auth/identity/register" do %> … <div class="field"> <%= label_tag :role %><br> <%= select :user, :role, User::ROLES %> </div> When I try and test the registration process I get the error message: Validation failed: Role can''t be blank The parameters are: {"utf8"=>"✓", "authenticity_token"=>"sSWArZADlbD1V9sUQGfP2pSsJSEOsIhu865mjdvI9to=", "name"=>"asdfasfd", "email"=>"1234123412341234", "user"=>{"role"=>"Customer"}, "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]", "commit"=>"Register", Can anyone suggest some changes in my code to allow the role to set in the user model from the omniauth registration form? Many thanks. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Walter Lee Davis
2012-Jan-18 19:21 UTC
Re: Adding a custom select to omniauth register form
On Jan 17, 2012, at 10:26 PM, Bob Fleming wrote:> Hi, > > I''m creating a rails app using omniauth 1.0.1 on Rails 3.1.3 and ruby > 1.9.2 > > I''m having trouble adding a select field that populates from a class > constant in my user model. > > Here''s my model: > > class User < ActiveRecord::Base > ROLES = ["Customer","Service Supplier"] > > has_many :leads > > validates_presence_of :role > > def self.from_omniauth(auth) > ... > end > > def self.create_with_omniauth(auth) > ... > end > > end > > > Here''s a snippet of my view from identities/new.html.erb: > > <%= form_tag "/auth/identity/register" do %> > … > > <div class="field"> > <%= label_tag :role %><br> > <%= select :user, :role, User::ROLES %> > </div> >What do the fields that send the omniauth credentials look like? I''m betting that the role attribute isn''t included in the same group of parameters. Walter> > When I try and test the registration process I get the error message: > > Validation failed: Role can''t be blank > > The parameters are: > {"utf8"=>"✓", > "authenticity_token"=>"sSWArZADlbD1V9sUQGfP2pSsJSEOsIhu865mjdvI9to=", > "name"=>"asdfasfd", > "email"=>"1234123412341234", > "user"=>{"role"=>"Customer"}, > "password"=>"[FILTERED]", > "password_confirmation"=>"[FILTERED]", > "commit"=>"Register", > > > Can anyone suggest some changes in my code to allow the role to set in > the user model from the omniauth registration form? > > > Many thanks. > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi Walter, Thanks for the email. I forgot to mention that despite the error the user and identity are created. Just that the role field is blank in the database and you get the error I mentioned in my email. I''m not 100% sure how to display the fields that send the omniauth credentials - so I can answer your question. If you can help with this that would be great - I''ll do some googling in the meantime. Cheers. On Jan 19, 8:21 am, Walter Lee Davis <wa...-HQgmohHLjDZWk0Htik3J/w@public.gmane.org> wrote:> On Jan 17, 2012, at 10:26 PM, Bob Fleming wrote: > > > > > > > > > > > Hi, > > > I''m creating a rails app using omniauth 1.0.1 on Rails 3.1.3 and ruby > > 1.9.2 > > > I''m having trouble adding a select field that populates from a class > > constant in my user model. > > > Here''s my model: > > > class User < ActiveRecord::Base > > ROLES = ["Customer","Service Supplier"] > > > has_many :leads > > > validates_presence_of :role > > > def self.from_omniauth(auth) > > ... > > end > > > def self.create_with_omniauth(auth) > > ... > > end > > > end > > > Here''s a snippet of my view from identities/new.html.erb: > > > <%= form_tag "/auth/identity/register" do %> > > … > > > <div class="field"> > > <%= label_tag :role %><br> > > <%= select :user, :role, User::ROLES %> > > </div> > > What do the fields that send the omniauth credentials look like? I''m betting that the role attribute isn''t included in the same group of parameters. > > Walter > > > > > > > > > > > When I try and test the registration process I get the error message: > > > Validation failed: Role can''t be blank > > > The parameters are: > > {"utf8"=>"✓", > > "authenticity_token"=>"sSWArZADlbD1V9sUQGfP2pSsJSEOsIhu865mjdvI9to=", > > "name"=>"asdfasfd", > > "email"=>"1234123412341234", > > "user"=>{"role"=>"Customer"}, > > "password"=>"[FILTERED]", > > "password_confirmation"=>"[FILTERED]", > > "commit"=>"Register", > > > Can anyone suggest some changes in my code to allow the role to set in > > the user model from the omniauth registration form? > > > Many thanks. > > > -- > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Walter Lee Davis
2012-Jan-18 21:16 UTC
Re: Re: Adding a custom select to omniauth register form
On Jan 18, 2012, at 3:20 PM, Bob Fleming wrote:> Hi Walter, > > Thanks for the email. > > I forgot to mention that despite the error the user and identity are > created. Just that the role field is blank in the database and you get > the error I mentioned in my email. > > I''m not 100% sure how to display the fields that send the omniauth > credentials - so I can answer your question.Well, look in the view file for that form, and see what you see there. If you''re creating the select field, you must be adding it to the same view file that contains the rest of the form, otherwise you wouldn''t see it. Walter> > If you can help with this that would be great - I''ll do some googling > in the meantime. > > Cheers. > > On Jan 19, 8:21 am, Walter Lee Davis <wa...-HQgmohHLjDZWk0Htik3J/w@public.gmane.org> wrote: >> On Jan 17, 2012, at 10:26 PM, Bob Fleming wrote: >> >> >> >> >> >> >> >> >> >>> Hi, >> >>> I''m creating a rails app using omniauth 1.0.1 on Rails 3.1.3 and ruby >>> 1.9.2 >> >>> I''m having trouble adding a select field that populates from a class >>> constant in my user model. >> >>> Here''s my model: >> >>> class User < ActiveRecord::Base >>> ROLES = ["Customer","Service Supplier"] >> >>> has_many :leads >> >>> validates_presence_of :role >> >>> def self.from_omniauth(auth) >>> ... >>> end >> >>> def self.create_with_omniauth(auth) >>> ... >>> end >> >>> end >> >>> Here''s a snippet of my view from identities/new.html.erb: >> >>> <%= form_tag "/auth/identity/register" do %> >>> … >> >>> <div class="field"> >>> <%= label_tag :role %><br> >>> <%= select :user, :role, User::ROLES %> >>> </div> >> >> What do the fields that send the omniauth credentials look like? I''m betting that the role attribute isn''t included in the same group of parameters. >> >> Walter >> >> >> >> >> >> >> >> >> >>> When I try and test the registration process I get the error message: >> >>> Validation failed: Role can''t be blank >> >>> The parameters are: >>> {"utf8"=>"✓", >>> "authenticity_token"=>"sSWArZADlbD1V9sUQGfP2pSsJSEOsIhu865mjdvI9to=", >>> "name"=>"asdfasfd", >>> "email"=>"1234123412341234", >>> "user"=>{"role"=>"Customer"}, >>> "password"=>"[FILTERED]", >>> "password_confirmation"=>"[FILTERED]", >>> "commit"=>"Register", >> >>> Can anyone suggest some changes in my code to allow the role to set in >>> the user model from the omniauth registration form? >> >>> Many thanks. >> >>> -- >>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en. > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi Walter, Thanks again. I''ve replied directly to your google groups registered email address wa...-HQgmohHLjDYU04JRNCRQjg@public.gmane.org I thought it might be more appropriate. Let me know if you get that ok or if you prefer me to continue using the google group. Cheers. On Jan 19, 10:16 am, Walter Lee Davis <wa...-HQgmohHLjDZWk0Htik3J/w@public.gmane.org> wrote:> On Jan 18, 2012, at 3:20 PM, Bob Fleming wrote: > > > Hi Walter, > > > Thanks for the email. > > > I forgot to mention that despite the error the user and identity are > > created. Just that the role field is blank in the database and you get > > the error I mentioned in my email. > > > I''m not 100% sure how to display the fields that send the omniauth > > credentials - so I can answer your question. > > Well, look in the view file for that form, and see what you see there. If you''re creating the select field, you must be adding it to the same view file that contains the rest of the form, otherwise you wouldn''t see it. > > Walter > > > > > > > > > > > If you can help with this that would be great - I''ll do some googling > > in the meantime. > > > Cheers. > > > On Jan 19, 8:21 am, Walter Lee Davis <wa...-HQgmohHLjDZWk0Htik3J/w@public.gmane.org> wrote: > >> On Jan 17, 2012, at 10:26 PM, Bob Fleming wrote: > > >>> Hi, > > >>> I''m creating a rails app using omniauth 1.0.1 on Rails 3.1.3 and ruby > >>> 1.9.2 > > >>> I''m having trouble adding a select field that populates from a class > >>> constant in my user model. > > >>> Here''s my model: > > >>> class User < ActiveRecord::Base > >>> ROLES = ["Customer","Service Supplier"] > > >>> has_many :leads > > >>> validates_presence_of :role > > >>> def self.from_omniauth(auth) > >>> ... > >>> end > > >>> def self.create_with_omniauth(auth) > >>> ... > >>> end > > >>> end > > >>> Here''s a snippet of my view from identities/new.html.erb: > > >>> <%= form_tag "/auth/identity/register" do %> > >>> … > > >>> <div class="field"> > >>> <%= label_tag :role %><br> > >>> <%= select :user, :role, User::ROLES %> > >>> </div> > > >> What do the fields that send the omniauth credentials look like? I''m betting that the role attribute isn''t included in the same group of parameters. > > >> Walter > > >>> When I try and test the registration process I get the error message: > > >>> Validation failed: Role can''t be blank > > >>> The parameters are: > >>> {"utf8"=>"✓", > >>> "authenticity_token"=>"sSWArZADlbD1V9sUQGfP2pSsJSEOsIhu865mjdvI9to=", > >>> "name"=>"asdfasfd", > >>> "email"=>"1234123412341234", > >>> "user"=>{"role"=>"Customer"}, > >>> "password"=>"[FILTERED]", > >>> "password_confirmation"=>"[FILTERED]", > >>> "commit"=>"Register", > > >>> Can anyone suggest some changes in my code to allow the role to set in > >>> the user model from the omniauth registration form? > > >>> Many thanks. > > >>> -- > >>> 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-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.orgm. > >>> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > >>> For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en. > > > -- > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Reasonably Related Threads
- linkedin login using omniauth
- “Routing Error No route matches {}” when omniauth failed on registration
- Windows, Rails 3.1.3, Omniauth-BrowserID, SSL Erro
- how to scope the /auth/:provider/callback , using OmniAuth for users and members
- Omniauth facebook authentication failure