Complete validation failures

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 %>

<%= f.label :level %>
<%= select_tag :level, options_for_select([["Base", 1], ["Silver", 2], ["Gold", 3]]) %>

<%= f.label :active %>
<%= f.check_box :active %>

<%= f.label "Benefit Type" %>
<%= f.select :type, options_for_select([["Points", 1],["Perks", 2]]) %>

<%= f.label :description %>
<%= f.text_area :description, :size => "60x10" %>

<%= f.label "Points earned for $ spent"%>
<%= f.select :point_conversion_ratio, options_for_select((1..10).to_a.collect{|x| [x] * 2}) %>

<%= f.label "Bonus Type" %> <%= f.select :bonus_type, options_for_select([["None", 0], ["Points", 1], ["Point Multiplier", 2], ["Special Perk", "3"]]) %>

<%= f.label :point_bonus %>
<%= f.text_field :point_bonus %>

<%= f.label :point_bonus_multiplier %>
<%= f.select :point_bonus_multiplier, options_for_select((1..10).to_a.collect{|x| [x] * 2}) %>

<%= f.label :perk_bonus %>
<%= f.text_area :perk_bonus, :size => "60x10" %>

<%= f.label :bonus_window_start %>
<%= f.datetime_select :bonus_window_start %>

<%= f.label :bonus_window_end %>
<%= f.datetime_select :bonus_window_end %>

<%= f.submit 'Create' %>

badnaam,

The following should have f.select.

<%= select_tag :level, options_for_select([[“Base”, 1], [“Silver”,
2], [“Gold”, 3]]) %>

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs