I’m creating a custom view that is a slight modification of the index.html.erb. I’d like to be able to create a link on my web app that directs a user to this custom view called list.html.erb.
Here’s what I’ve done:
1) Copied the default scaffold index view and renamed it to list.html.erb
2) Modified GalleriesController by copying the index method and renaming to list:
def list
@galleries = Gallery.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @galleries }
end
end
3) Modified routes.rb file like so:
match "galleries/list" => "galleries#list"
I keep getting the following error:
Couldn't find Gallery with ID=list
Rails.root: /Users/scervera/Sites/MDN
Application Trace | Framework Trace | Full Trace
app/controllers/galleries_controller.rb:28:in `show'
In my search on stackoverflow I was unable to find any similar questions.
I’m guessing you put the
matchoutside of, and after, the galleryresourcesrouting.This means the
listis being interpreted as the:idof the default RESTful mapping.Options include:
indexunless you truly need them both (which seems weird).listRESTful action as described here (see below).To add the
listaction (option 2):