On 10/1/09, djolley <ddjol...@gmail.com> wrote:
>
>> Have you read this?
>> http://guides.rubyonrails.org/routing.html
>
> Yes, I have.  However, because of your referral I have taken a fresh
> look.  It is still none too clear to me.  Here is what I get:
>
> The respond_to block allows us to assign separate action code and a
> separate response to each different format.  I'm thinking that a
> "response" is a view template; but, I'm not sure.  It also appears
> that part of what is going on is to get render to set the content-type
> header appropriately.  For example, the 'render :xml' causes the
> content-type header to be set to "application/xml".  I'm not sure how
> the template file should be named.  For example, should it be,
> "read.csv"?  I don't know what content-type is associated with the csv
> format.
>
> As you can see, I still have quite a bit missing.  Any further
> clarifying comments would be appreciated.  Thanks.
>
>          ... doug

Ok, just to clarify a bit more, as Marnen said, a template is not
mandatory, is just the default.
Take a look a this example:
http://pastie.org/638500

I took it for some book and modified it just a bit.
With format html, it will search for the default export.html.erb
template, but for csv, it will behave differently.
The example here uses fastercsv, which will let you handle csv in a
nice way, but nevermind it for now, you should asume that you'll have
a variable with the csv data you want to return, and you'll return it
with the send_data method (you can chech de ri doc for this later),
setting the content-type and suggesting a file name to be saved.
So my point here is to show you how you can answer from an action
without having a template and considering more that one format.
Anyway, it seems that you're focusing on the wrong thing, you should
read more about ActionController (ri doc or the guide on the ruby on
rails site should be fine), this is not a routing problem.

Hope it helps.

Cheers.

-- 
Leonardo Mateo.
There's no place like ~

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to