Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 473465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T00:11:22+00:00 2026-05-13T00:11:22+00:00

Wanting to play with jQuery, Orbited, and FasterCSV, I made a Rails chat application.

  • 0

Wanting to play with jQuery, Orbited, and FasterCSV, I made a Rails chat application.

You can browse to a URL and there is a chat window that is similar to IRC. You can also export the contents of the chat window by visiting the same URL but adding a “.csv” extension to the URL.

HTML version: http://host.name/channel/sweetchatroom

CSV version: http://host.name/channel/sweetchatroom.csv

In Firefox, Safari, and Chrome it works normal. In IE, If I visit the “HTML” URL, I get the CSV version of the page. I have to manually add “.html” to the URL like so:

http://host.name/channel/sweetchatroom.html

My route currently looks like this:

map.chat '/channel/:name.:format', :controller => 'channels', :action => 'show'

I Googled a bit and tried the following suggestions:

map.slug '/channel/:slug.:format', :controller => 'channels', :action => 'show', :defaults => {:format => 'html'}

— and —

map.slug '/channel/:slug.:format', :controller => 'channels', :action => 'show', :format => 'html'

Neither of them worked. Apparently, if you visit a URL without specifying the format, Rails does not set params[:format] to anything. Which in principle I prefer, but the docs are pretty clear that you can set a default format and I’m not sure why it doesn’t honor this. The “:defaults => …” suggestion is what is in the Rails docs.

In order to get it to work I had to change this part of my channels controller:

respond_to do |format|
  format.csv { 
    send_data channel_to_csv(@channel),
      :type => "text/plain",
      :filename => "#{@channel.slug}.csv",
      :disposition => 'inline'
  } 
  format.html # show.html.erb
  format.xml  { render :xml => @channel }
end

To this:

respond_to do |format|
  format.csv { 
    send_data channel_to_csv(@channel),
      :type => "text/plain",
      :filename => "#{@channel.slug}.csv",
      :disposition => 'inline'
  } if params[:format] == 'csv' # <-- Here is the change
  format.html # show.html.erb
  format.xml  { render :xml => @channel }
end

It works perfectly but seems really hackish. There has to be a better, more “Ruby” way. Do I have the syntax wrong on my routes entry? It seems like routes is where this should be.

I know I have to be missing something. I couldn’t find good information on this problem on Google or on StackOverflow. That generally means I’m way out in the weeds.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T00:11:22+00:00Added an answer on May 13, 2026 at 12:11 am

    I usually just put the format.html first. That way, when IE sends a weird accepts header (like */*), it doesn’t get fouled up. Basically, if IE says it accepts everything (like when there is no extension on the URL) Rails will send it the first thing that matches.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm wanting to create a program that you can import an mp3 file into,
I'm wanting to play around with creating an LR parser generators. Does anyone know
I've been wanting to have a play with either Ruby or Python while at
Not wanting to re-invent the wheel or anything, I was wondering if there's a
Bit of a random one, i am wanting to have a play with some
I am wanting to load FLV videos from S3 server into my Flash application.
We are wanting to add support for fingerprint authentication in a .Net 3.5 application.
Have gotten the foundation in place, but now, finding myself wanting to play around
I'd like to play around with rails 3, but I'm still used to rails
I find myself wanting to write a routine that will operate on both volatile

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.