Hi Walter,

Thanks again.

I've replied directly to your google groups registered email address
wa...@wdstudio.com.

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 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 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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
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@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

Previous

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 5 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