【发布时间】:2011-03-31 22:36:03
【问题描述】:
我想通过 activeresource 创建一个新客户。没有 authentication_key 没什么大不了的。我正在使用设计身份验证和 cancan。
customer = Customer.create(:fname=>'sampath , :last_name=>'munasinghe' ,:auth_token=>'af34afafasfasfasaf')
如果我使用上面的代码创建一个新客户,对 web 服务器的 xml 请求是
Parameters: {"customer"=>{"first_name"=>'sampath', "last_name"=>"munasinghe", "auth_token"=>"af34afafasfasfasaf"}}
客户模型包装的问题 id auth_token。因此,身份验证失败并返回 401 响应。
有什么解决方案可以创建这种格式的请求吗?
参数:{"customer"=>{"first_name"=>'sampath', "last_name"=>"munasinghe"}, "auth_token"=>"af34afafasfasfasaf"}}
注意:auth_token 在客户块之外。
谢谢
【问题讨论】:
标签: ruby-on-rails activeresource