Ruby on rails 3 如何在RubyonRails3中从模型进行路由和渲染(分派)
我想从模型中分派(路由和渲染)。(我只关心Ruby on rails 3 如何在RubyonRails3中从模型进行路由和渲染(分派),ruby-on-rails-3,routing,Ruby On Rails 3,Routing,我想从模型中分派(路由和渲染)。(我只关心GET请求,而忽略Accept:标题,所以我只查看PATH\u INFO) FWIW这是我的路线文件: # config/routes.rb MyApp::Application.routes.draw do resources :products # GET /products.json?merchant_id=foobar match '/:id(.:format)'
GET
请求,而忽略Accept:
标题,所以我只查看PATH\u INFO
)
FWIW这是我的路线文件:
# config/routes.rb
MyApp::Application.routes.draw do
resources :products # GET /products.json?merchant_id=foobar
match '/:id(.:format)' => 'contents#show', :via => 'get' # GET /examples
root :to => 'contents#index', :via => 'get' # GET /
end
另请参见:实际上比这更容易:
session = ActionDispatch::Integration::Session.new(Rails.application)
session.get(path_info)
self.body = session.response.body
# config/routes.rb
MyApp::Application.routes.draw do
resources :products # GET /products.json?merchant_id=foobar
match '/:id(.:format)' => 'contents#show', :via => 'get' # GET /examples
root :to => 'contents#index', :via => 'get' # GET /
end
session = ActionDispatch::Integration::Session.new(Rails.application)
session.get(path_info)
self.body = session.response.body