我设置了两个操作来从数据库中获取特定项目,如下所示:
路线.rb
match 'bibles' => 'documents#bibles'
match 'postcards' => 'documents#postcards'
文档控制器.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
它们呈现一个特定的视图,两者都包含相同的代码,bibles.html.erb
并且postcards.html.erb
. 我需要这个指向相同的观点。是否有要添加到路由的参数来执行此操作,或者我的路由是否不正确?