views:

17

answers:

1

This question is related to this other question: http://stackoverflow.com/questions/2003732/change-rails-text-field-form-builder-type

I have a JQuery Tools Range in my form, and making it work requires that the input field be of the type "date". Rails doesn't easily allow me to do this so I've used a manual tag as follows:

<% form_for @customer, :url => {:action => "update", :id => @customer} do |f| %>
...
<%= tag(:input, {:type => :range, :value => f.object.travel, :name => "travel", :min => "0", :max => "100" }) %>
...
<% end %>

This tag shows the range slider. It also displays the right value from the database. However, when I submit a change, the "travel" attribute is sent as a general attribute and not under "customer". So, my database doesn't update.

How can I rewrite the tag so it gets included as a "customer" attribute?

+1  A: 

Try:

<%= tag(:input, {:type => :range, :value => f.object.travel, :name => "customer[travel]", :min => "0", :max => "100" }) %>
jenjenut233