0

Rails 3.2.0 | Ruby 1.9.2

Route:

xyz_catalog_device_info 
GET|POST /xyz/catalog/devices/:device_id/info(.:format)
xyz/catalog/devices#info`

My app wraps up several API services into one system to provide a single place to maintain SSL Certificates and complicated XML generation logic. My controller makes an HTTP call to a 3rd party API to obtain the information, so there's no XYZ::Catalog::Device persisting (no @device) to implement the usual rails form helper tricks.

I want to create a form like the following:

%form{ :action => xyz_catalog_device_info_path(:format => :xml) }
  = label_tag :device_id, "Device ID:"
  = text_field_tag :device_id
  = submit_tag "Search"

so that it will fill in the device_id in the action.

Is this possible without using javascript? Is there a better way of doing this?

CITguy
  • 198
  • 1
  • 2
  • 9

1 Answers1

0

Sounds like what you are looking for is http://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html

Where you would just use soemthing like...

= form_tag(xyz_catalog_device_info_path(:format => :xml)) do
  = label_tag :device_id, "Device ID:"
  = text_field_tag :device_id
  = submit_tag "Search"
  • That's doing pretty much the same thing that I asked for the form. However, I'm trying to submit a form that contains an input field for the resource identifier (device_id) to an action path that also requires that identifier ( /xyz/catalog/devices/:device_id/info.xml ). – CITguy Aug 23 '12 at 04:29