All the validations fail, even though the values in the params[] are
valid. Here is the error in the logs, this is very weird frustrating,
this should be pretty straightforward
rails version 2.3.5
Model =>
class LoyaltyBenefit < ActiveRecord::Base
belongs_to :merchant
validates_inclusion_of :level, :in => 1..3
validates_inclusion_of :type, :in => 1..2, :message => "{{value}}
is not a valid type"
validates_numericality_of :point_conversion_ratio, :greater_than
=> 0
end
Processing LoyaltyBenefitsController#create (for 127.0.0.1 at
2010-04-11 14:36:48) [POST]
Parameters: {"merchant_id"=>"6",
"loyalty_benefit"=>{"bonus_window_start(2i)"=>"4",
"bonus_window_start(3i)"=>"11", "bonus_window_start(4i)"=>"19",
"bonus_window_end(1i)"=>"2010", "bonus_window_end(2i)"=>"4",
"bonus_window_start(5i)"=>"42", "type"=>"1",
"bonus_window_end(3i)"=>"11", "point_bonus"=>"",
"bonus_window_end(4i)"=>"19", "description"=>"",
"bonus_window_end(5i)"=>"42", "perk_bonus"=>"", "bonus_type"=>"0",
"point_bonus_multiplier"=>"1", "bonus_window_start(1i)"=>"2010",
"point_conversion_ratio"=>"2", "active"=>"1"}, "commit"=>"Create",
"authenticity_token"=>"qNZURLMMX7sx/d80y1F4n4Ks+FRsLwHKWeepB6uz9+s=",
"level"=>"1"}
[4;35;1mUser Load (0.0ms) [0m [0mSELECT * FROM `users` WHERE
(`users`.`id` = '64') LIMIT 1 [0m
[4;36;1mSQL (0.0ms) [0m [0;1mBEGIN [0m
[4;35;1mUser Update (0.0ms) [0m [0mUPDATE `users` SET
`perishable_token` = 'nsdERTv9Xf0aATzuqtjt', `updated_at` =
'2010-04-11 21:36:48', `last_request_at` = '2010-04-11 21:36:48' WHERE
`id` = 64 [0m
[4;36;1mAssignment Load (0.0ms) [0m [0;1mSELECT * FROM
`assignments` WHERE (`assignments`.user_id = 64) [0m
[4;35;1mSQL (62.0ms) [0m [0mCOMMIT [0m
[4;36;1mMerchant Columns (0.0ms) [0m [0;1mSHOW FIELDS FROM
`merchants` [0m
[4;35;1mMerchant Load (0.0ms) [0m [0mSELECT * FROM `merchants`
WHERE (`merchants`.`id` = 6) [0m
[4;36;1mLoyaltyBenefit Columns (0.0ms) [0m [0;1mSHOW FIELDS FROM
`loyalty_benefits` [0m
[4;35;1mSQL (0.0ms) [0m [0mBEGIN [0m
[4;36;1mSQL (0.0ms) [0m [0;1mROLLBACK [0m
View =>
<% form_for(@loyalty_benefit, :url =>
merchant_loyalty_benefits_path(@merchant)) do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :level %><br />
<%= select_tag :level, options_for_select([["Base", 1], ["Silver",
2], ["Gold", 3]]) %>
</p>
<p>
<%= f.label :active %><br />
<%= f.check_box :active %>
</p>
<p>
<%= f.label "Benefit Type" %><br />
<%= f.select :type, options_for_select([["Points", 1],["Perks",
2]]) %>
</p>
<p style="display: none" id="perk_description">
<%= f.label :description %><br />
<%= f.text_area :description, :size => "60x10" %>
</p>
<p id="point_conversion">
<%= f.label "Points earned for $ spent"%><br />
<%= f.select :point_conversion_ratio,
options_for_select((1..10).to_a.collect{|x| [x] * 2}) %>
</p>
<p>
<%= f.label "Bonus Type" %>
<%= f.select :bonus_type, options_for_select([["None", 0],
["Points", 1], ["Point Multiplier", 2], ["Special Perk", "3"]]) %>
</p>
<p id ="bonus1" style="display: none">
<%= f.label :point_bonus %><br />
<%= f.text_field :point_bonus %>
</p>
<p id ="bonus2" style="display: none">
<%= f.label :point_bonus_multiplier %><br />
<%= f.select :point_bonus_multiplier,
options_for_select((1..10).to_a.collect{|x| [x] * 2}) %>
</p>
<p style="display: none" id ="bonus3">
<%= f.label :perk_bonus %><br />
<%= f.text_area :perk_bonus, :size => "60x10" %>
</p>
<div style="display: none" id ="bonus_window">
<span>
<%= f.label :bonus_window_start %><br />
<%= f.datetime_select :bonus_window_start %>
</span>
<br/>
<span>
<%= f.label :bonus_window_end %><br />
<%= f.datetime_select :bonus_window_end %>
</span>
</div>
<p>
<%= f.submit 'Create' %>
</p>
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.