I have two actions set up to get specific items from database as follows:
routes.rb
match 'bibles' => 'documents#bibles'
match 'postcards' => 'documents#postcards'
documents_controller.rb
def bibles
@pagetitle = "Browse all Bibles"
@documents = Document.where(:document_type_id => 1).paginate(:page =>params[:page], :order =>'id desc', :per_page =>50)
end
def postcards
@pagetitle = "Browse all Postcards"
@documents = Document.where(:document_type_id => 3).paginate(:page =>params[:page], :order =>'id desc', :per_page =>50)
end
These render a specific view, both of which consist of the same code, bibles.html.erb and postcards.html.erb. I need this to point to the same view. Is there a parameter to add to the route that will do this, or is my routing incorrect for this purpose?
just add
render "documents"to your actions, and name your viewdocuments.html.erb.