未定义的方法`confirm_password' - 这是否意味着AuthLogic没有触发我的请求?

时间:2009-11-30 11:04:07

标签: ruby-on-rails authlogic

几乎有Authlogic example类型的rails应用程序设置。我 单击注册的链接时出现以下错误。从一般的角度来看,我无法看到视图“form.label:confirm_password”如何支持在不引发问题的情况下运行,并注意到该字段在数据库的User表中不存在?

Q1 - AuthLogic如何阻止此形式“confirm_password” 要立即传回模式?

Q2 - 任何想法在我的案例中出现问题以及如何解决它?通常Rails在处理时如何处理忽略表单中的“confirm_password”类型字段,其方式是在控制器阶段需要它(a)但是(b)在后端active_record阶段不需要。

ActionView::TemplateError (undefined method `confirm_password' for
#<User:0x2703fbc>) on line #8 of app/views/users/_form.erb:
5: <%= form.password_field :password %><br />
6: <br />
7: <%= form.label :confirm_password%><br />
8: <%= form.password_field :confirm_password %><br />
9: <br />

/opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/attribute_methods.rb:260:in `method_missing'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_view/
helpers/form_helper.rb:835:in `send'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_view/
helpers/form_helper.rb:835:in `value_before_type_cast'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_view/
helpers/form_helper.rb:823:in `value_before_type_cast'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_view/
helpers/form_helper.rb:744:in `to_input_field_tag'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_view/
helpers/form_helper.rb:557:in `password_field'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_view/
helpers/form_helper.rb:943:in `send'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_view/
helpers/form_helper.rb:943:in `password_field'
/Users/greg/Dropbox/source/myapp/app/views/users/_form.erb:8:in
`_run_erb_app47views47users47_form46erb_locals_form_object'
/Users/greg/Dropbox/source/myapp/app/views/users/new.html.erb:5:in
`_run_erb_app47views47users47new46html46erb'
/Users/greg/Dropbox/source/myapp/app/views/users/new.html.erb:3:in
`_run_erb_app47views47users47new46html46erb'

macintosh-2:myapp greg$ find . -name *.rb | xargs grep -i confirm_password
./app/controllers/application_controller.rb:
filter_parameter_logging :password, :confirm_password

问候

1 个答案:

答案 0 :(得分:0)

必须将其更改为“:password_confirmation”并且它有效 - 这是一个AuthLogic的事情....