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

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.

Search Discussions

Discussion Posts


Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 5 of 5 | next ›
Discussion Overview
grouprubyonrails-talk @
postedSep 24, '12 at 5:24p
activeSep 25, '12 at 9:06p



site design / logo © 2022 Grokbase