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 549303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:10:13+00:00 2026-05-13T11:10:13+00:00

I have a standard restful rails application. format.html { @users = User.find(:all, :limit =>

  • 0

I have a standard restful rails application.

format.html { @users = User.find(:all, :limit => 10)}
format.csv { @users = User.find(:all, :limit => 10) }

When the url is

http://localhost:3000/users.csv

I get a file with name users.csv .

However if the url is

http://localhost:3000/users?format=csv

then the file I get has name users. I would like to have file name to be users.csv .

  • 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-13T11:10:13+00:00Added an answer on May 13, 2026 at 11:10 am

    This is the browser’s default file naming coming into play. The browser doesn’t know anything about the meaning of the format parameter. It just sees the resource being accessed is called ‘users’, so it defaults to that file name.

    In the former example, the resource being requested is called users.csv, so it uses that as the default file name.

    You may also want to look into the Content-Disposition HTTP header. This will cause the browser to prompt the user to save the file with a specified file name as the default (the user is free to change that though), instead of displaying the file in the browser. Thus, you could have your resource be http://localhost:3000/users?format=csv, but default the file name to foo.csv with this header:

    Content-disposition: attachment; filename=foo.csv
    

    Check out this Microsoft link for some more information. The concept is the same for rails as it is for any HTTP technology.

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

Sidebar

Related Questions

I have a Rails application that right now is pretty standard: Heroku/PostgreSQL backend, users
I have a form which I'd like to save through a standard RESTful rails
I've heard they have standard GUI guideline, but I can't seem to find a
I am building a Rails application which allows a user to create an object
In my Rails app I have a fairly standard has_many relationship between two entities.
I have standard ruby-head and Rails 3.1rc4. I installed ruby-debug with following instructions from
I have a Rails application with several models-views-controllers which have some similar characteristics, for
Let's say I have a Rails 3 app that displays videos. The user can
So say I have a RESTFul API that has the standard GET , POST
if have standard socket.io setup: var app = require('http').createServer().listen(80,'127.0.5.12'), io = require('socket.io').listen(app); session =

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.