Ruby on Rails Tuesday, September 25, 2012

On 09/24/2012 01:18 PM, jason baguio wrote:
> I am using Devise and am trying to allow each user to create 1
> profile (they can currently make many). I am able to send the the
> newly registered user to the page where they can create a profile,
> but when the User logs in it will not go to the Profile Show page
> - the error message is
>
> (Couldn't find Profile without an ID...
> app/controllers/profiles_controller.rb:16:in `show')

We dealt with a similar problem by making sure that a profile was
created for every user at the time the user is created; we did this in
the model after failing to convince the controller to do the right thing.

In app/models/user.rb:

before_save do | user |
user.profile = Profile.new unless user.profile
end

HTH,
Chris
--
Chris Maden, text nerd <URL: http://crism.maden.org/ >
LIVE FREE: vote for Gary Johnson, Libertarian for President.
<URL: http://garyjohnson2012.com/ > <URL: http://lp.org/ >
GnuPG fingerprint: DB08 CF6C 2583 7F55 3BE9 A210 4A51 DBAC 5C5C 3D5E

--
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 https://groups.google.com/groups/opt_out.

No comments:

Post a Comment