rails serving different content types through a method
I have a cms system for multiple clients. Now i have the following controller:开发者_C百科 websites with 2 methods: index and public.
I would like to serve different types of content through that method. So it could be images, js, css etc.
But how to accomplish this! of course i have this extention.. for example /index.css i check if it exists and then i want to render it. But how to do this with different types of content ?
Have you tried respond_to
?
def index
respond_to do |format|
format.html # will render views/some_controller/index.html.erb
format.js # will render views/some_controller/index.js.erb
end
end
etc
精彩评论