del82 / ezra

ezra on rails
2 stars 1 forks source link

hit#show throws a 500 if the hit's target has a "multiple"-type feature associated #52

Closed del82 closed 11 years ago

nmashton commented 11 years ago

This seems to only be the case if the feature had some valued features prior to the "multiple"-type feature being associated with its target.

If you try to edit hit 10012, it'll throw a 500. This was the hit which I had been playing with; I had already given it values for the "single"-type features that were previously associated with its target.

But if you try to edit 10013, that works just fine. The difference can only be the fact that this hit was blank, whereas 10012 already had some content before its target was changed.

del82 commented 11 years ago

Nope, the feature being valued or not doesn't seem to make a difference-- I've valued the features in 10013 and 10014 and it's still fine. I copied the production database to my local machine and don't get the same problem. Here's the exception trace from the log:

Processing by HitsController#edit as HTML
  Parameters: {"id"=>"10012"}
  Rendered hits/_error_messages.html.erb (0.1ms)
  Rendered hits/edit.html.erb within layouts/application (67.1ms)
Completed 500 Internal Server Error in 73ms

ActionView::Template::Error (undefined method `include?' for nil:NilClass):
    192:             <% feature.fvalues.each_with_index do |value,val_index| %>
    193:               <label class="checkbox">
    194:                 <% if(has_saved_feature)
    195:                     has_value = @hit.feat_vals["#{index}"].include?(value)
    196:                   end
    197:                 %>
    198:                 <%= check_box_tag("hit[feat_vals][#{index}][]",value,has_value,:class => "needs-validation") %>
  app/views/hits/edit.html.erb:195:in `block (3 levels) in _app_views_hits_edit_html_erb___3399681303465201833_69867212745640'
  app/views/hits/edit.html.erb:192:in `each'
  app/views/hits/edit.html.erb:192:in `each_with_index'
  app/views/hits/edit.html.erb:192:in `block (2 levels) in _app_views_hits_edit_html_erb___3399681303465201833_69867212745640'
  app/views/hits/edit.html.erb:165:in `block in _app_views_hits_edit_html_erb___3399681303465201833_69867212745640'
  app/views/hits/edit.html.erb:5:in `_app_views_hits_edit_html_erb___3399681303465201833_69867212745640'
parryc commented 11 years ago

My guess is that some how hit 10012 got deleted from the database. It's failing because @hit (hit number 10012) doesn't exist.

(I don't know how to get on to Plath or I'd check this myself)

del82 commented 11 years ago

Nope, that's not it. 10012 is still there. (I just copied the current plath production db to http://plath.compling.cornell.edu/production.sqlite3 so you can download it if you like.)

The way I read that exception trace, @hit.feat_vals["#{index}"] is nil, not the hit itself-- otherwise it'd say undefined method 'feat_vals' for nil:NilClass

parryc commented 11 years ago

Got it (I think). It'll crash if you add a feature to a hit that's already been annotated. I've added a second check to default to no selection if there's no data assigned to a new feature when editing a hit.

Fixed in 7b74e63