Skip to content

Instantly share code, notes, and snippets.

@tmichel
Last active August 29, 2015 14:14
Show Gist options
  • Select an option

  • Save tmichel/94f33dca318b31dbdeb5 to your computer and use it in GitHub Desktop.

Select an option

Save tmichel/94f33dca318b31dbdeb5 to your computer and use it in GitHub Desktop.
Ransack using ActiveRecord and Monogid side by side

Ransack using ActiveRecord and Monogid side by side

To reproduce bug:

$ bundle install
$ ruby person.rb

An error is thrown when trying to use an ActiveRecord model:

ransack-1.6.3/lib/ransack/context.rb:30:in `for': Don't know what context to use for Person (ArgumentError)
# A sample Gemfile
source "https://rubygems.org"
gem 'activerecord'
gem 'mongoid'
gem 'sqlite3'
gem 'ransack'
require 'bundler/setup'
require 'active_record'
require 'mongoid'
require 'ransack'
ActiveRecord::Base.establish_connection(
:adapter => 'sqlite3',
:database => 'test.db'
)
class CreatePerson < ActiveRecord::Migration
def change
create_table :people do |t|
t.string :name
t.timestamps
end
end
end
CreatePerson.migrate(:up)
class Person < ActiveRecord::Base; end
Person.ransack(name_contains: 'john')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment