I am trying to create a registration process similar to SO:
- route to the OpenID provider
- the provider returns user information to the UserController (suppose)
- UsersController creates the user, then routes to the new or editable ProfilesController action.
I'm currently just trying to create a user, then redirecting to a new or editing ProfilesController action (not sure what I should use).
Here is what I still have:
Models:
class User < ActiveRecord::Base has_one :profile end class Profile < ActiveRecord::Base belongs_to :user end
Routes
map.resources :users do |user| user.resource :profile end new_user_profile GET /users/:user_id/profile/new(.:format) {:controller=>"profiles", :action=>"new"} edit_user_profile GET /users/:user_id/profile/edit(.:format) {:controller=>"profiles", :action=>"edit"} user_profile GET /users/:user_id/profile(.:format) {:controller=>"profiles", :action=>"show"} PUT /users/:user_id/profile(.:format) {:controller=>"profiles", :action=>"update"} DELETE /users/:user_id/profile(.:format) {:controller=>"profiles", :action=>"destroy"} POST /users/:user_id/profile(.:format) {:controller=>"profiles", :action=>"create"} users GET /users(.:format) {:controller=>"users", :action=>"index"} POST /users(.:format) {:controller=>"users", :action=>"create"} new_user GET /users/new(.:format) {:controller=>"users", :action=>"new"} edit_user GET /users/:id/edit(.:format) {:controller=>"users", :action=>"edit"} user GET /users/:id(.:format) {:controller=>"users", :action=>"show"} PUT /users/:id(.:format) {:controller=>"users", :action=>"update"} DELETE /users/:id(.:format) {:controller=>"users", :action=>"destroy"}
Controllers
class UsersController < ApplicationController
User Edit:
... <% form_for(@user) do |f| %> ...
New profile:
... <% form_for([@user,@profile]) do |f| %> ..
I have two problems:
What am I missing?
I looked at Linking two models in Rails (user and profile) , but that didn't concern my needs.
Thank you for your time.
craig source share