为什么我在使用authlhogic在rails 2中创建用户模板时遇到错误?

时间:2011-04-20 06:46:36

标签: ruby-on-rails controller authlogic

我得到以下错误:

  

UsersController#创建   (ActionView :: MissingTemplate)“失踪   视图路径中的模板用户/ create.erb   应用程序/意见“

但我不知道为什么:这是我的控制器:

1 class UsersController < ApplicationController
  2 
  3   before_filter :require_no_user, :only => [:new, :create]
  4   before_filter :require_user, :only => [:show, :edit, :update]
  5 
  6   def new
  7     @user = User.new
  8   end
  9 
 10   def create
 11 
 12     @user = User.new(params[:user])
 13     debugger
 14     @user.save do |result|
 15       debugger
 16       if result
 17         debugger
 18         flash[:notice] = "Account registered!"
 19         debugger
 20         redirect_back_or_default campaign_path
 21       else
 22         debugger
 23         render :action => :new
 24       end
 25 
 26     end
 27   end

1 个答案:

答案 0 :(得分:1)

我可能只是将@ user.save放在if语句中而不是发送一个块。尝试做这样的事情:

def create
  @user = User.new(params[:user])
  if @user.save
    flash[:notice] = "Account registered!"
    redirect_back_or_default campaign_path
  else
    render :action => :new
  end
end