azamsharp
azamsharp

Reputation: 20094

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.

Upvotes: 1

Views: 106

Answers (2)

Denis Hennessy
Denis Hennessy

Reputation: 7473

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.

Upvotes: 1

Hugo
Hugo

Reputation: 2913

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.

Upvotes: 1

Related Questions