rails validation of presence not failing on nil
- by holden
I want to make sure an attibute exists, but it seems to still slip thru and I'm not sure how better to check for it.
This should work, but doesn't. It's a attr_accessor and not a real attribute if that makes a difference.
validates_presence_of :confirmed, :rooms
{"commit"=>"Make Booking",
"place_id"=>"the-kosmonaut",
"authenticity_token"=>"Tkd9bfGqYFfYUv0n/Kqp6psXHjLU7CmX+D4UnCWMiMk=",
"utf8"=>"✓",
"booking"=>{"place_id"=>"6933",
"bookdate"=>"2010-11-22",
"rooms"=>[{}],
"no_days"=>"2"}}
Not sure why my form_for returns a blank hash in an array...
<% form_for :booking, :url => place_bookings_path(@place) do |f| %>
<%= f.hidden_field :bookdate, { :value => user_cart.getDate } %>
<%= f.hidden_field :no_days, { :value => user_cart.getDays } %>
<% for room in pricing_table(@place.rooms,@valid_dates) %>
<%= select_tag("booking[rooms][][#{room.id}]", available_beds(room)) %>
<% end %>
<% end %>