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@googlegroups.com.
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.

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 5 | next ›
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedJan 18, '12 at 5:10p
activeJan 18, '12 at 10:00p
posts5
users2
websiterubyonrails.org
irc#RubyOnRails

2 users in discussion

Bob Fleming: 3 posts Walter Lee Davis: 2 posts

People

Translate

site design / logo © 2021 Grokbase