开发者

Rails 3 Rspec form_for Deprecation Warning

I have a form_for in my application which looks like:

<%= form_for :user, @user, :url =&g开发者_运维问答t; { :controller => 'users', :action => 'update' }, :html => { :multipart => true, :method => 'put' } do |f| %>

This works fine. However, when I run my tests with Rspec I always get:

DEPRECATION WARNING: Using form_for(:name, @resource) is deprecated. Please use form_for(@resource, :as => :name) instead.

Which seems to go against what is written in the Rails 3 forms guide. Is this just a bug in rspec or is it actually a deprecation?


You should just be able to do this

<%= form_for @user, :html => {:multipart => true} %>

Since Rails will know that @user is an existing record, it'll know to do a PUT request to users_controller#update.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜