Я получаю эту ошибку при попытке зарегистрировать нового пользователя.undefined метод `save 'for nil: NilClass
NoMethodError (не определен метод save' for nil:NilClass): app/controllers/users_controller.rb:49:in
создать ' приложение/контроллеры/users_controller.rb: 48: в `создать'
class UsersController < ApplicationController
before_filter :require_no_user, :only => [:new, :create]
before_filter :require_user, :only => [:show, :edit, :update]
#filter_resource_access
def index
@users = User.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @users }
end
end
def show
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @user }
end
end
def new
#@user = User.new
@carriers = Carrier.find(:all)
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @user }
end
end
def edit
end
def create
@user = User.new(params[:user])
if @user.save
flash[:notice] = "Account registered!"
redirect_back_or_default account_url
else
render :action => :new
end
end
def profile
@user = User.find(params[:id])
end
def update
respond_to do |format|
if @user.update_attributes(params[:user])
format.html { redirect_to(@user, :notice => 'User was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @user.errors, :status => :unprocessable_entity }
end
end
end
def destroy
@user = User.find(params[:id])
@user.destroy
respond_to do |format|
format.html { redirect_to(users_url) }
format.xml { head :ok }
end
end
def delete
@user = User.find(params[:user_id])
@user.destroy
redirect_to :users
end
end
Можете ли вы вставить класс модели пользователя из приложения/models/user.rb? – Kunday