User & Profile w/ Devise

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')

The code (sorted by files) is below…

user.rb

# == Schema Information

Have you checked that profile id is being passed in params[:id]?

KUL KING wrote in post #1077336:

Have you checked that profile id is being passed in params[:id]?

How ought I check this?

jason baguio wrote in post #1077357:

KUL KING wrote in post #1077336:

Have you checked that profile id is being passed in params[:id]?

How ought I check this?

I changed changed the application_controller.rb to:

class ApplicationController < ActionController::Base   def after_sign_in_path_for(resource)     request.env['omniauth.origin'] || stored_location_for(resource) || show_path(resource.profile)   end end

I signed up a new User and then created a Profile. After I logged out and signed back in it gave me the error:

ActiveRecord::RecordNotFound in ProfilesController#show

Couldn't find Profile without an ID

Any thoughts on the issue?

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