1
我正在嘗試在我的一個控制器上編寫自定義操作的請求規範。在rspec中命名自定義路由
我的routes.rb是這樣的:
controller :profile, :path => 'profile' do
match 'view_friends/:circle_id', :to => :view_friends, :via => [:get], :as => 'view_friends'
end
resources :profile
我想訪問這個動作,並希望我可以用
visit profile_path
visit new_profile_path
etc
,我可以做
visit view_friends_profile_path
但是,這給了我「錯誤未定義的局部變量或方法」
我可以通過寫
visit profile_path.to_s + '/view_friends/' + circle.id.to_s
獲得所需的行爲但是,這是可怕的。我錯過了什麼可以命名自定義操作?
編輯:從耙路線
view_friends GET (/:locale)/profile/view_friends/:circle_id(.:format) {:controller=>"profile", :action=>"view_friends"}
運行rake路由以確保您使用的是正確的幫助程序方法。也許你可以將命令的輸出添加到問題中。 – lucapette 2011-12-21 13:54:13
你能解決問題嗎? – Batkins 2011-12-21 22:21:29