- changed status to invalid
Attendee-model not validating children
Issue #21
invalid
When a new Attendee validates successfully, but one of the nested models (Preference, Foodpreference) does not validate, there will be an attendee in the database with no nested properties. This will generate errors like this:
Started GET "/anmalan" for 127.0.0.1 at 2014-09-07 19:40:15 +0200
Processing by AttendeesController#new as HTML
Parameters: {"locale"=>"sv"}
Attendee Load (0.2ms) SELECT "attendees".* FROM "attendees" WHERE "attendees"."id" = ? LIMIT 1 [["id", 15]]
Preference Load (0.1ms) SELECT "preferences".* FROM "preferences" WHERE "preferences"."attendee_id" = ? LIMIT 1 [["attendee_id", 15]]
Rendered attendees/show.html.erb within layouts/application (1.8ms)
Completed 500 Internal Server Error in 5ms
ActionView::Template::Error (undefined method `get_price' for nil:NilClass):
18: <p>
19: Beställning:<br />
20: <% pref = @attendee.preference %>
21: <% price = pref.get_price %>
22: <% alcohol_free = !pref.alcohol ? ', alkoholfritt' : '' %>
23: <% if pref.student %>
24: <%= 'Student' + alcohol_free + ': ' +
app/views/attendees/show.html.erb:21:in `_app_views_attendees_show_html_erb__4367436513131865681_43787340'
app/controllers/attendees_controller.rb:12:in `new'
Rendered /home/fredrik/.gem/ruby/2.1.0/gems/actionpack-4.1.4/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (1.3ms)
Rendered /home/fredrik/.gem/ruby/2.1.0/gems/actionpack-4.1.4/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (1.0ms)
Rendered /home/fredrik/.gem/ruby/2.1.0/gems/actionpack-4.1.4/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb within rescues/layout (9.2ms)
Comments (2)
-
reporter -
reporter - removed milestone
Removing milestone: Beta av färdigt system (DL: 7/9) (automated comment)
- Log in to comment
Only relevant for pull request #16