princelab/rails-metric_site — Issue #7: Syntax error on Comparisons submit
Author: ryanmt
Created: 2011-12-05 18:32:20+00:00
State: open

I'm seeing an error when loading a new comparison. It happens on the redirect... It shows the following:

NoMethodError in Comparisons#show

Showing /home/ryanmt/Dropbox/coding/rails/metrics_site/app/views/comparisons/show.html.haml where line #2 raised:

undefined method `id' for nil:NilClass
Extracted source (around line #2):

1: - @comparison ||= Comparison.get(params[:id])
2: %h1= "Comparison ##{@comparison.id}"
3: %p User Description: #{ @comparison.description }
#{link_to "Edit", edit_comparison_path(@comparison)}
4: %ul.categories
5: - ApplicationHelper::Categories.each do |cat|
Rails.root: /home/ryanmt/Dropbox/coding/rails/metrics_site

Application Trace | Framework Trace | Full Trace
app/views/comparisons/show.html.haml:2:in `_app_views_comparisons_show_html_haml__4489259300140243539_28432640'
Request

Parameters:

{"id"=>"31"}
Show session dump

Show env dump

Response

Headers:

None

#Comments: The controller should be delivering the `@comparisons` object, but I was seeing this error before and was able to catch it by performing the ` ||= Comparison.get(params[:id])` assignment when `@comparisons` wasn't assigned from the controller. I wonder if this is a database level issue where the Comparison isn't generated before it is queried... Any thoughts?