【发布时间】:2013-08-30 16:24:56
【问题描述】:
我有一个 Rails 应用程序,并定制了设计视图,以添加一些与 Angular 的交互性。所以,我的输入看起来像
<input id="user_name" name="name" ng-blur="isNameBusy()" type="text">
(省略所有不必要的属性)
这意味着发送表单时的请求如下所示:
Parameters: {"utf8"=>"✓", "authenticity_token"=>"xxx", "name"=>"test", "email"=>"test@mail.com", "password"=>"[FILTERED]", "commit"=>"Sign up"}
但是 devise 不理解这个请求,因为默认情况下,devise 视图中的输入具有 name 属性,例如:
<input id="user_name" name="user[name]" ng-blur="isNameBusy()" type="text">
<input id="user_email" name="user[email]" type="email">
请求看起来像:
Parameters: {"utf8"=>"✓", "authenticity_token"=>"xxx", "user"=>{"name"=>"test", "email"=>"test@mail.com", "password"=>"[FILTERED]"}, "commit"=>"Sign up"}
你看,字段被包裹在 user 键中。
当然,我可以在我的 js 中使用默认的设计名称,比如
registerForm.user[name].$valid
但它看起来很丑! 如何让设计人员理解我的要求?
【问题讨论】:
标签: ruby-on-rails angularjs devise