几乎都安装了Authlogic example类型的rails应用程序。当我点击已注册的链接时,我得到了以下错误。从一般的观点来看,我不太明白如何支持"form.label :confirm_password“视图在不引发问题的情况下运行,注意到该字段不存在于数据库的用户表中?
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问候
发布于 2009-11-30 19:26:33
我不得不把它改成":password_confirmation“,它起作用了--这是AuthLogic的事情……
https://stackoverflow.com/questions/1819154
复制相似问题