Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed undefined method version_key for ActiveRecord::Associations::JoinD... #235

Closed
wants to merge 1 commit into from

Conversation

linkrjr
Copy link

@linkrjr linkrjr commented Jun 11, 2013

The missing version_key method error can be simulated by running a simple join on versions

Ex.: Address.joins(:versions).where("unit_number = ':n'", :n => 1000).to_a

Where the address and the custom version classes are defined as follows

class Address < ActiveRecord::Base
  has_paper_trail :class_name => 'AddressVersion', :on => [:update], :meta => {:unit_number => :unit_number, :house_number => :house_number, :house_suffix => :house_suffix}
end

class AddressVersion < Version
  self.table_name = :address_versions
  attr_accessible :unit_number, :house_number, :house_suffix, :event, :object, :whodunnit
end

@batter
Copy link
Collaborator

batter commented Jun 11, 2013

This should be unnecessary, what is the error is being raised? What returns if you invoke Address.version_key? What returns if you invoke AddressVersion.primary_key?

@linkrjr
Copy link
Author

linkrjr commented Jun 12, 2013

Invoking either Address.version_key or AddressVersion.primary_key returns the right primary key name but the problem I am having is that when joining Addresses and Versions, the lambda gets a JoinAssociation/Relation rather than a model and so, the code "_model.class" throws a method_missing exception for version_key.

The lambda is being invoked on a JoinAssociation/Relation scope, not a model.

@batter
Copy link
Collaborator

batter commented Jun 12, 2013

Hmm... I'd like to attempt reproduce this locally. Are you using Rails4? I'm guessing thats the case since this is the rails4 branch you are pulling against. Do you have a sample app I could clone to play around with?

I attempted to reproduce this with a similar query against a Rails 3 app I have setup and the query caused this error to be thrown:

ActiveRecord::StatementInvalid: SQLite3::SQLException: ambiguous column name: source_file_id: SELECT "resource_versions".* FROM "resource_versions" INNER JOIN "versions" ON "versions"."item_id" = "resource_versions"."id" AND "versions"."item_type" = 'ResourceVersion' WHERE (source_file_id = '15')

Can you please print the error message that's being returned by Rails as well?

@linkrjr
Copy link
Author

linkrjr commented Jun 13, 2013

Yes, I am using Rails4.
I don't have a sample app as it is a client's project but it is really just a simple one-to-many relationship here so any model with a has_paper_trail defined should raise the exception when joining it with versions.

Here it is the error message:

NoMethodError - undefined method `version_key' for ActiveRecord::Associations::JoinDependency::JoinAssociation:Class:
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/paper_trail-e1d590fe16cb/lib/paper_trail/has_paper_trail.rb:63:in `block in has_paper_trail'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activerecord/lib/active_record/associations/join_dependency/join_association.rb:111:in `block (2 levels) in join_to'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activerecord/lib/active_record/associations/join_dependency/join_association.rb:109:in `block in join_to'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activerecord/lib/active_record/associations/join_dependency/join_association.rb:74:in `join_to'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activerecord/lib/active_record/relation/query_methods.rb:951:in `block in build_joins'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activerecord/lib/active_record/relation/query_methods.rb:950:in `build_joins'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activerecord/lib/active_record/relation/query_methods.rb:802:in `build_arel'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activerecord/lib/active_record/relation/query_methods.rb:795:in `arel'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activerecord/lib/active_record/relation.rb:585:in `exec_queries'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activerecord/lib/active_record/relation.rb:471:in `load'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activerecord/lib/active_record/relation.rb:220:in `to_a'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activerecord/lib/active_record/relation.rb:573:in `inspect'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activerecord/lib/active_record/relation/delegation.rb:16:in `rescue in each'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activerecord/lib/active_record/relation/delegation.rb:12:in `each'
  app/views/properties/_list.html.haml:14:in `_app_views_properties__list_html_haml__1662234641523019985_70202103027660'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_view/template.rb:143:in `block in render'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activesupport/lib/active_support/notifications.rb:159:in `block in instrument'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activesupport/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activesupport/lib/active_support/notifications.rb:159:in `instrument'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_view/template.rb:141:in `render'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_view/renderer/partial_renderer.rb:306:in `render_partial'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_view/renderer/partial_renderer.rb:279:in `block in render'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activesupport/lib/active_support/notifications.rb:159:in `block in instrument'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activesupport/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activesupport/lib/active_support/notifications.rb:159:in `instrument'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_view/renderer/partial_renderer.rb:278:in `render'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_view/renderer/renderer.rb:47:in `render_partial'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_view/helpers/rendering_helper.rb:27:in `render'
  haml (4.0.3) lib/haml/helpers/action_view_mods.rb:10:in `block in render_with_haml'
  haml (4.0.3) lib/haml/helpers.rb:89:in `non_haml'
  haml (4.0.3) lib/haml/helpers/action_view_mods.rb:10:in `render_with_haml'
  app/views/properties/index.html.haml:17:in `block in _app_views_properties_index_html_haml__2967478691416831709_70202101432600'
  haml (4.0.3) lib/haml/helpers/action_view_mods.rb:45:in `block in capture_with_haml'
  haml (4.0.3) lib/haml/helpers.rb:368:in `block in capture_haml'
  haml (4.0.3) lib/haml/helpers.rb:617:in `with_haml_buffer'
  haml (4.0.3) lib/haml/helpers.rb:364:in `capture_haml'
  haml (4.0.3) lib/haml/helpers/xss_mods.rb:61:in `capture_haml_with_haml_xss'
  haml (4.0.3) lib/haml/helpers/action_view_mods.rb:45:in `capture_with_haml'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_view/helpers/rendering_helper.rb:83:in `_layout_for'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_view/renderer/partial_renderer.rb:307:in `block in render_partial'
  app/views/shared/_tabs.html.haml:9:in `_app_views_shared__tabs_html_haml___3054204885270347658_70202102893780'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_view/template.rb:143:in `block in render'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activesupport/lib/active_support/notifications.rb:159:in `block in instrument'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activesupport/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activesupport/lib/active_support/notifications.rb:159:in `instrument'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_view/template.rb:141:in `render'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_view/renderer/partial_renderer.rb:306:in `render_partial'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_view/renderer/partial_renderer.rb:279:in `block in render'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activesupport/lib/active_support/notifications.rb:159:in `block in instrument'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activesupport/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activesupport/lib/active_support/notifications.rb:159:in `instrument'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_view/renderer/partial_renderer.rb:278:in `render'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_view/renderer/renderer.rb:47:in `render_partial'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_view/helpers/rendering_helper.rb:22:in `render'
  haml (4.0.3) lib/haml/helpers/action_view_mods.rb:12:in `render_with_haml'
  app/views/properties/index.html.haml:16:in `_app_views_properties_index_html_haml__2967478691416831709_70202101432600'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_view/template.rb:143:in `block in render'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activesupport/lib/active_support/notifications.rb:159:in `block in instrument'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activesupport/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activesupport/lib/active_support/notifications.rb:159:in `instrument'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_view/template.rb:141:in `render'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_view/renderer/template_renderer.rb:49:in `block (2 levels) in render_template'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activesupport/lib/active_support/notifications.rb:159:in `block in instrument'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activesupport/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activesupport/lib/active_support/notifications.rb:159:in `instrument'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_view/renderer/template_renderer.rb:48:in `block in render_template'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_view/renderer/template_renderer.rb:56:in `render_with_layout'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_view/renderer/template_renderer.rb:47:in `render_template'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_view/renderer/template_renderer.rb:17:in `render'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_view/renderer/renderer.rb:42:in `render_template'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_view/renderer/renderer.rb:23:in `render'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/abstract_controller/rendering.rb:127:in `_render_template'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_controller/metal/streaming.rb:219:in `_render_template'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/abstract_controller/rendering.rb:120:in `render_to_body'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_controller/metal/rendering.rb:33:in `render_to_body'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_controller/metal/renderers.rb:26:in `render_to_body'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/abstract_controller/rendering.rb:97:in `render'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_controller/metal/rendering.rb:16:in `render'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_controller/metal/instrumentation.rb:41:in `block (2 levels) in render'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activesupport/lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
  /Users/ronaldogomes/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/benchmark.rb:296:in `realtime'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activesupport/lib/active_support/core_ext/benchmark.rb:12:in `ms'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_controller/metal/instrumentation.rb:41:in `block in render'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_controller/metal/instrumentation.rb:84:in `cleanup_view_runtime'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activerecord/lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_controller/metal/instrumentation.rb:40:in `render'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_controller/metal/implicit_render.rb:10:in `default_render'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_controller/metal/implicit_render.rb:5:in `send_action'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/abstract_controller/base.rb:189:in `process_action'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_controller/metal/rendering.rb:10:in `process_action'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activesupport/lib/active_support/callbacks.rb:473:in `_run__3352990975113176737__process_action__callbacks'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activesupport/lib/active_support/callbacks.rb:80:in `run_callbacks'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/abstract_controller/callbacks.rb:17:in `process_action'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_controller/metal/rescue.rb:29:in `process_action'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activesupport/lib/active_support/notifications.rb:159:in `block in instrument'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activesupport/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activesupport/lib/active_support/notifications.rb:159:in `instrument'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_controller/metal/params_wrapper.rb:245:in `process_action'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activerecord/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/abstract_controller/base.rb:136:in `process'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/abstract_controller/rendering.rb:44:in `process'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_controller/metal.rb:195:in `dispatch'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_controller/metal.rb:231:in `block in action'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_dispatch/routing/route_set.rb:80:in `dispatch'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_dispatch/routing/route_set.rb:48:in `call'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_dispatch/journey/router.rb:71:in `block in call'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_dispatch/journey/router.rb:59:in `call'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_dispatch/routing/route_set.rb:655:in `call'
  meta_request (0.2.6) lib/meta_request/middlewares/app_request_handler.rb:13:in `call'
  rack-contrib (1.1.0) lib/rack/contrib/response_headers.rb:17:in `call'
  meta_request (0.2.6) lib/meta_request/middlewares/headers.rb:16:in `call'
  meta_request (0.2.6) lib/meta_request/middlewares/meta_request_handler.rb:13:in `call'
  rack (1.5.2) lib/rack/etag.rb:23:in `call'
  rack (1.5.2) lib/rack/conditionalget.rb:25:in `call'
  rack (1.5.2) lib/rack/head.rb:11:in `call'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_dispatch/middleware/params_parser.rb:27:in `call'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_dispatch/middleware/flash.rb:241:in `call'
  rack (1.5.2) lib/rack/session/abstract/id.rb:225:in `context'
  rack (1.5.2) lib/rack/session/abstract/id.rb:220:in `call'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_dispatch/middleware/cookies.rb:486:in `call'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activerecord/lib/active_record/query_cache.rb:36:in `call'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:626:in `call'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activesupport/lib/active_support/callbacks.rb:373:in `_run__1149450153065904727__call__callbacks'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activesupport/lib/active_support/callbacks.rb:80:in `run_callbacks'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_dispatch/middleware/reloader.rb:64:in `call'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
  better_errors (0.9.0) lib/better_errors/middleware.rb:84:in `protected_app_call'
  better_errors (0.9.0) lib/better_errors/middleware.rb:79:in `better_errors_call'
  better_errors (0.9.0) lib/better_errors/middleware.rb:56:in `call'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/railties/lib/rails/rack/logger.rb:38:in `call_app'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/railties/lib/rails/rack/logger.rb:21:in `block in call'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activesupport/lib/active_support/tagged_logging.rb:67:in `block in tagged'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activesupport/lib/active_support/tagged_logging.rb:25:in `tagged'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activesupport/lib/active_support/tagged_logging.rb:67:in `tagged'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/railties/lib/rails/rack/logger.rb:21:in `call'
  quiet_assets (1.0.2) lib/quiet_assets.rb:18:in `call_with_quiet_assets'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_dispatch/middleware/request_id.rb:21:in `call'
  rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
  rack (1.5.2) lib/rack/runtime.rb:17:in `call'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/activesupport/lib/active_support/cache/strategy/local_cache.rb:83:in `call'
  rack (1.5.2) lib/rack/lock.rb:17:in `call'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/actionpack/lib/action_dispatch/middleware/static.rb:64:in `call'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/railties/lib/rails/engine.rb:511:in `call'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/railties/lib/rails/application.rb:97:in `call'
  rack (1.5.2) lib/rack/content_length.rb:14:in `call'
  thin (1.5.1) lib/thin/connection.rb:81:in `block in pre_process'
  thin (1.5.1) lib/thin/connection.rb:79:in `pre_process'
  thin (1.5.1) lib/thin/connection.rb:54:in `process'
  thin (1.5.1) lib/thin/connection.rb:39:in `receive_data'
  eventmachine (1.0.3) lib/eventmachine.rb:187:in `run'
  thin (1.5.1) lib/thin/backends/base.rb:63:in `start'
  thin (1.5.1) lib/thin/server.rb:159:in `start'
  rack (1.5.2) lib/rack/handler/thin.rb:16:in `run'
  rack (1.5.2) lib/rack/server.rb:264:in `start'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/railties/lib/rails/commands/server.rb:84:in `start'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/railties/lib/rails/commands.rb:80:in `block in <top (required)>'
   () Users/ronaldogomes/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-14fda489bde9/railties/lib/rails/commands.rb:75:in `<top (required)>'
  bin/rails:4:in `<main>'

@batter
Copy link
Collaborator

batter commented Jun 18, 2013

Ok did some poking around with this today, setup a dummy app, and went back and reviewed the purpose of that method. Seems that the version_key method was introduced as a fix for #177.

As discussed on that issue thread, it sounds like we may be able to remove the secondary sort on the primary key entirely as the timestamp field appears to be sufficient for sorting. This seems like it is probably a better resolution than invoking the primary_key directly, as with your proposed solution, #177 could still be produced. I'll make that modification on both the rails4 and version3 branches.

@batter batter closed this Jun 18, 2013
batter pushed a commit that referenced this pull request Oct 10, 2013
…al with ordering to use the timestamp_field for ordering instead of the primary key to keep consistent with the change that was made for #235
@batter batter mentioned this pull request Oct 22, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants