Reputation: 11
Rails 4.0.1 and devise 3.4.1
Receiving the following error, regardless whether it's sign_in or sign_up:
NoMethodError in Devise::SessionsController#create
undefined method `user_changed?' for #
Devise doesn't generate any controllers by default, and none were added; there isn't a registrations or sessions_controller.
User Model:
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable, :registerable
mount_uploader :user, ImageUploader
end
Routes:
Myapp::Application.routes.draw do
devise_for :users
resources :posts
resources :projects
resources :contacts, only: [:new, :create]
get 'welcome/index'
root 'welcome#index'
get '*path' => redirect('/')
end
Routes Table:
Prefix Verb URI Pattern Controller#Action
new_user_session GET /users/sign_in(.:format) devise/sessions#new
user_session POST /users/sign_in(.:format) devise/sessions#create
destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy
user_password POST /users/password(.:format) devise/passwords#create
new_user_password GET /users/password/new(.:format) devise/passwords#new
edit_user_password GET /users/password/edit(.:format) devise/passwords#edit
PATCH /users/password(.:format) devise/passwords#update
PUT /users/password(.:format) devise/passwords#update
cancel_user_registration GET /users/cancel(.:format) devise/registrations#cancel
user_registration POST /users(.:format) devise/registrations#create
new_user_registration GET /users/sign_up(.:format) devise/registrations#new
edit_user_registration GET /users/edit(.:format) devise/registrations#edit
PATCH /users(.:format) devise/registrations#update
PUT /users(.:format) devise/registrations#update
DELETE /users(.:format) devise/registrations#destroy
posts GET /posts(.:format) posts#index
POST /posts(.:format) posts#create
new_post GET /posts/new(.:format) posts#new
edit_post GET /posts/:id/edit(.:format) posts#edit
post GET /posts/:id(.:format) posts#show
PATCH /posts/:id(.:format) posts#update
PUT /posts/:id(.:format) posts#update
DELETE /posts/:id(.:format) posts#destroy
projects GET /projects(.:format) projects#index
POST /projects(.:format) projects#create
new_project GET /projects/new(.:format) projects#new
edit_project GET /projects/:id/edit(.:format) projects#edit
project GET /projects/:id(.:format) projects#show
PATCH /projects/:id(.:format) projects#update
PUT /projects/:id(.:format) projects#update
DELETE /projects/:id(.:format) projects#destroy
contacts POST /contacts(.:format) contacts#create
new_contact GET /contacts/new(.:format) contacts#new
welcome_index GET /welcome/index(.:format) welcome#index
root GET / welcome#index
Code from app\views\devise\registrations\new.html.erb
<%= form_for(resource, as: resource_name, url: user_registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
And finally, code from devise\sessions\new.html.erb:
<%= form_for(resource, as: resource_name, url: user_session_path(resource_name)) do |f| %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
</div>
Would greatly appreciate any help to regain the ability to sign back in or sign up.
Thanks
Upvotes: 0
Views: 442
Reputation: 7339
The registrations and sessions controllers are built into devise.
I'm guessing this broke when you added u user photo?
Do you really have a field on your user table called user
that holds your image? If you so, you need to create a migration to create that name.
rails g migration rename_user_photo_field
Edit hte file
class RenameUserPhoto < ActiveRecord::Migration
def change
rename_column :users, :user, :photo
end
end
Upvotes: 0