views:

13

answers:

1

Hi guys

I have a cms system for multiple clients. Now i have the following controller: 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 ?

+1  A: 

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

PeterWong
thanxs!. but it is actually in websites/#{client_id}/ So that would only work if it would be in the views dir. Also i doubt that it would render images :P
OH edit.. my bad. i read up .. maybe it is possible! thanxs! :) (i will give it a try..
ya, it supports images :D
PeterWong
well i edited the mime_types.. so my app now supports everything! ;)