开发者

Weird Routing Error in Rails When Manually Adding View

I am not sure what I am doing wrong but when I manually add the view "blah.html.erb" to my project and then visit myproject/dog/blah. It says the following:

Routing Error

No route matches "/dog/blah"

There is an action defined in DogController called "blah" which is the following:

开发者_高级运维
def blah 

end 

NOTE: I add the view using TextMate. I add a new blank file. I think there is some wrong encoding attached to the .html.erb file.


For clarity, you need to either have each action listed explicitly in your routes.rb file; or you need a wildcard pattern to match the controller and action.


What's in your routes.rb file?

Better yet, you need to have something like this

match "/dog/blah", :to => "dog#blah", :as => :dog_blah

This tells your rails app that the url /dog/blah maps to the blah action in your DogController, and the :as option will give you a named route that you can use in your view in this case dog_blah_path.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜