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

Broken for Rails 4.2 - here's how to fix #97

Closed
danbartlett opened this issue Jan 21, 2015 · 5 comments
Closed

Broken for Rails 4.2 - here's how to fix #97

danbartlett opened this issue Jan 21, 2015 · 5 comments

Comments

@danbartlett
Copy link

After upgrading to rails 4.2 we started experiencing Undefined method column_for_attribute

I eventually came across #95 which lead me to this pull request https://github.com/elia/activeadmin-mongoid/pull/96/files

I tried using:

gem 'activeadmin-mongoid', github: 'pencilcheck/activeadmin-mongoid', branch: 'patch-1'

Which fixed my first error, but then raised another error about _ransack not being available. So I looked at the pull request again, and tried re-adding what pencilcheck removed:

module ActiveAdmin
  module Filters
    module FormtasticAddons

      # The resource class, unwrapped from Ransack
      def klass
        @object.klass
      end

    end
  end
end

After adding this in to one of my models, everything works again!

@danbartlett
Copy link
Author

@pencilcheck, any thoughts?

@pencilcheck
Copy link
Contributor

@danbartlett I believe you would also want to include master branch to activeadmin/activeadmin.

e.g. gem 'activeadmin', github: 'activeadmin', branch: 'master'

But including a moving target is dangerous, so I pick one commit

e.g. gem 'activeadmin', github: 'activeadmin', ref: '54bed'

Also, I have a fork of ransack that adds embedded documents in this PR: activerecord-hackery/ransack#498

If you are interested just include this before activeadmin and activeadmin-mongoid:
gem 'ransack', github: 'pencilcheck/ransack', branch: 'patch-1'

Hope that works for you.

@pencilcheck
Copy link
Contributor

If you are getting an error about "$oid", maybe this snippet from this issue heartcombo/devise#2949 would help:

#HACK FOR DEVISE 3.2.4
def self.serialize_into_session(record)
[record.id.to_s, record.authenticatable_salt]
end
Put it in the user class used for devise

@pisaq
Copy link

pisaq commented Jan 29, 2015

It is working for me so far. Extra much appreciate :)

@mzdemezer
Copy link

I managed to solve Undefined method column_for_attribute by adding initializer:

module Mongoid
  module Document
    def column_for_attribute(attribute)
      type = fields[attribute.to_s].type.to_s.underscore.split('/').last.to_sym
      Struct.new(:type).new(type)
    end
  end
end

I hope this helps.

@boie0025 boie0025 closed this as completed Jun 6, 2017
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

No branches or pull requests

5 participants