开发者

Rails 3 - Couldn't find Photo with ID=quick

I created new model via scaffold and I added new action there - quick. To routes.rb I added get "photos开发者_开发问答/quick" and created the file qucik.html.erb (and it's in the right view-directory).

If I will set to browser localhost:3000/photos/quick, I will get the error above. In my controller it looks very simple:

def quick
end

And also in the view:

<div>this is template for quick action</div>

How is possible to get that error message? Why is run show action?

routes.rb:

FirstApp::Application.routes.draw do

  resources :photos
  get "photos/quick"

   root :to => "photos#index"

end


Change routes to use collection and fix the code structure to use the blocks properly:

FirstApp::Application.routes.draw do    
  resources :photos do
    collection do
      get "quick"
    end
  end
  root :to => "photos#index"
end

See some documentation here about such routes

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜