更新用户而不提供密码时出现模板丢失错误 - Authlogic

时间:2011-08-05 17:21:59

标签: ruby-on-rails ruby authentication authlogic

我在我的客户端的Rails 2.3.8应用程序中使用Authlogic作为我的身份验证系统。我有一个模型,CommunityEventUser,需要使用新属性进行更新。控制器代码是这样的:

  def edit
    @user = current_user 
  end

  def update
    @user = current_user
    if @user.update_attributes(params[:community_event_user])
      flash[:notice] = "You updated your profile!"
      redirect_to community_event_user_path
    else
      render :action => :edit
    end
  end

这只是标准的编辑/更新RESTful代码。当我转到视图以编辑用户帐户信息时,提交包含passwordpassword_confirmation之外的任何属性的更改的表单,并将最后两个字段留空以将我重定向到包含此错误的页面:

Template is missing

Missing template community_event_users/edit.erb in view path app/views

这个网址:

http://localhost:3000/events/user.%23%3Ccommunityeventuser:0x10495ad80%3E

但是,当我在两个密码字段中匹配密码时,用户会正确更新。我认为标准的Authlogic使用只允许在更新时忽略空白passwordpassword_confirmation字段。这可能是什么问题?

查看编辑代码:

- set_page_title "Login - Community Calendar"

%h2.replaced#h2-edit_account Edit Account

    - content_for :sidebar do
      = render :partial => 'community_events/sidebar'

    = render 'community_event_user'

1 个答案:

答案 0 :(得分:0)

而不是

render :action => :edit

你可以使用:

render :template => "community_event_users/edit"

那么,你有一个像这样的文件: “yourapp / views / community_event_users / edit.erb”?

如果没有,请使用edit-view-file的路径。