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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:02:51+00:00 2026-05-20T10:02:51+00:00

Environment: Rails 3.0.4 and Ruby 1.9.2 I have the following form: <%= form_tag( {:action

  • 0

Environment: Rails 3.0.4 and Ruby 1.9.2

I have the following form:

<%= form_tag( {:action => 'show', :format => :pdf}, :method => :post) do %>

.. list of items ...

<%= submit_tag "Show", :onclick => "return checkAllFields(4);", :remote => true %> 

<select name="format">
    <option name="HTML">HTML</option>
    <option name="PDF">PDF</option>
</select>) 

<% end %>

As you can see, I’ve specified the format to be ‘pdf’ in the URL. What I want, is to request either HTML or PDF response from the controller based on the select option. Both of the queries work individually i.e. I can render either HTML or PDF but can’t make it a dynamic user selection. (I can’t even make it work with two separate hard-coded buttons)

Controller code is obviously

def show
  # code to locate items here

  respond_to do |format|
    format.html
    format.pdf { render :layout => false }
      prawnto :filename => "list.pdf", :prawn => { }
  end 
end
  • 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-20T10:02:51+00:00Added an answer on May 20, 2026 at 10:02 am

    I would try the following:

    First, you may need to remove the hardcoded :format => :pdf from the form tag (as it may override the option, below).

    Next, make sure the select tag is passing the right values. There’s a helper you can use:

    select_tag :format, options_for_select([["HTML", "html"], ["PDF", "pdf"]], "html")
    

    which returns something like the following HTML:

    <select id='format' name='format'>
      <option value='html' selected='selected'>HTML</option>
      <option value='pdf'>PDF</option>
    </select>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

we have a mixed development environment using ASP.NET MVC and Ruby on Rails. We
Environment: Rails 3.2.3 Mac OS X Lion Ruby-1.9.3-p194 (MRI) I have a rails app
I have the following setup to send email at sign up: Rails 3.0.7 ruby
I am new to Rails & Ruby and have been following the http://ruby.railstutorial.org/ruby-on-rails-tutorial-book and
I am following along the Ruby on Rails Tutorial and have gotten somewhat confused
Environment: Rails 3.0.1 Ruby 1.8.7 MySQL 5.5.16 Community server...Jdk 1.6 gem 'sunspot_rails' gem 'sunspot_solr'
My Environment Rails 3.2.1 ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0] I want to change
My development environment: Ubuntu 9 Ruby 1.9.1/1.8.7 (rvm) Rails 2.3.5 Mysql 5.0 Apache Passenger
I have no rails environment but I want to use cruisecontrol.rb as my Continous
I have a rails environment which I set-up with macports. I recently updated macports

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.