I'm trying to integrate gem called slim_scrooge in my app but I keep getting some weird issue i.e getting the following error
NoMethodError: undefined method reverse' for nil:NilClass
from /Users/ratatouille/.rvm/gems/ruby-1.9.3-p547@minerva/gems/activerecord-3.2.10/lib/active_record/connection_adapters/abstract/database_statements.rb:11:in
block in to_sql'
Upon careful debugging I found that the error is getting produce on .to_sql
on arel.
To find it why I added the breakpoint on this line
and then I found this
## On First run
Performer.find(1985)
From: /Users/Ratatouille/.rvm/gems/ruby-1.9.3-p547@minerva/gems/activerecord-3.2.10/lib/active_record/relation.rb @ line 171 ActiveRecord::Relation#exec_queries:
166:
167: default_scoped = with_default_scope
168:
169: if default_scoped.equal?(self)
170: @records = if @readonly_value.nil? && !@klass.locking_enabled?
=> 171: binding.pry
172: eager_loading? ? find_with_associations : @klass.find_by_sql(arel, @bind_values)
173: else
174: IdentityMap.without do
175: eager_loading? ? find_with_associations : @klass.find_by_sql(arel, @bind_values)
176: end
[1] pry(#<ActiveRecord::Relation>)> arel.to_sql
=> "SELECT `performers`.* FROM `performers` WHERE `performers`.`id` = ? LIMIT 1"
## Second Run for same record
Performer.find(1985)
From: /Users/ratatouille/.rvm/gems/ruby-1.9.3-p547@minerva/gems/activerecord-3.2.10/lib/active_record/relation.rb @ line 171 ActiveRecord::Relation#exec_queries:
166:
167: default_scoped = with_default_scope
168:
169: if default_scoped.equal?(self)
170: @records = if @readonly_value.nil? && !@klass.locking_enabled?
=> 171: binding.pry
172: eager_loading? ? find_with_associations : @klass.find_by_sql(arel, @bind_values)
173: else
174: IdentityMap.without do
175: eager_loading? ? find_with_associations : @klass.find_by_sql(arel, @bind_values)
176: end
[1] pry(#<ActiveRecord::Relation>)> arel.to_sql
NoMethodError: undefined method `reverse' for nil:NilClass
from /Users/ratatouille/.rvm/gems/ruby-1.9.3-p547@minerva/gems/activerecord-3.2.10/lib/active_record/connection_adapters/abstract/database_statements.rb:11:in `block in to_sql'
I'm going Nut over the fact that why is the 2nd time the arel.to_sql doesn't work
Any one has a clue
More info -
- Rails 3.2.10