# Complete validation failures

**URL:** <https://www.ruby-forum.com/t/complete-validation-failures/186707>\
**Category:** Rails\
**Created:** [April 11, 2010, 11:42pm UTC](https://www.ruby-forum.com/t/complete-validation-failures/186707 "2010-04-11T23:42:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![badnaam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e36b37/32.png) [@badnaam](https://www.ruby-forum.com/u/badnaam)\
**Post date:** [April 11, 2010, 11:42pm UTC](https://www.ruby-forum.com/t/complete-validation-failures/186707/1 "2010-04-11T23:42:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![badnaam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e36b37/32.png) [@badnaam](https://www.ruby-forum.com/u/badnaam)\
**Post date:** [April 12, 2010, 11:58pm UTC](https://www.ruby-forum.com/t/complete-validation-failures/186707/2 "2010-04-12T23:58:18Z")

</div>

badnaam,

The following should have f.select.

\<%= select\_tag :level, options\_for\_select([[“Base”, 1], [“Silver”,  
2], [“Gold”, 3]]) %\>
