Reputation: 227
I used scaffold and created a controller model and view part and then I wanted to add a new page eg:search to it so I created search.html.erb in the
`views/myview/search.html.erb`
and in the routes.rb I added like this
resources :myview ,:collection => {:search => :get}
and in controller I added a action def search end .. but when I go to localhost:3000/myapp/myview/develop I get an error
Missing template myview/show, application/show with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder]}. Searched in: * "/path/app/views" * "/home/***/.rvm/gems/ruby-2.1.2/gems/devise-3.4.0/app/views"
I don't want a show page how do I fix this? I want to show my search.html.erb page
Upvotes: 0
Views: 369
Reputation: 3243
That's how you should declare your routes:
resources :myview do
collection do
get :search
end
end
As you typed localhost:3000/myapp/myview/develop
, Rails recognizes it as /myview/:id
and it is expected behaviour. If you want to add additional develop
action, then declare it within routes.rb
first.
Upvotes: 1