Document has_many and belongs_to error undefined method `programs_id_eq' for #<MetaSearch::Searches::MongoidSearchBuilder:0x007f388084da40> #63

Closed
edwinlunando opened this Issue Oct 8, 2013 · 5 comments

Comments

Projects
None yet
5 participants
@edwinlunando

So, I used

gem 'mongoid'
gem 'carrierwave-mongoid', :require => 'carrierwave/mongoid'
gem 'activeadmin-mongoid', '~> 0.3.0'

The mongoid version is 3.1.5. I have two models GroupProgram and Program. The relation is simple GroupProgram has_many Program and Program belongs_to GroupProgram. here is the code

class GroupProgram
  include Mongoid::Document
  include Mongoid::Timestamps

  field :title, type: String
  field :description, type: String
  has_many :programs

  attr_accessible :title, :description, :programs
end
class Program
  include Mongoid::Document
  include Mongoid::Timestamps

  field :title, type: String
  field :description, type: String
  belongs_to :group_program

  # todo add image uploader
end

Okay, the http://127.0.0.1:3000/admin/group_programs URL give me errors NoMethodError at /admin/group_programs
undefined method `programs_id_eq' for #<MetaSearch::Searches::MongoidSearchBuilder:0x007f388084da40.

@david-boyd

This comment has been minimized.

Show comment Hide comment
@david-boyd

david-boyd Oct 9, 2013

+1 I also have the same issue.

+1 I also have the same issue.

@david-boyd

This comment has been minimized.

Show comment Hide comment
@david-boyd

david-boyd Oct 10, 2013

Found a possible workaround, seems if you specify filters ( i.e. don't let activeadmin try to create filters for has_many) then you don't get this error.

Found a possible workaround, seems if you specify filters ( i.e. don't let activeadmin try to create filters for has_many) then you don't get this error.

@elia

This comment has been minimized.

Show comment Hide comment
@elia

elia Oct 10, 2013

Member

Even better we could try to fix the metasearch mongoid builder. The code is inside aa-mongoid and should be straightforward.

https://github.com/elia/activeadmin-mongoid/blob/master/lib/meta_search/searches/mongoid.rb

The places to look at are the method_missing and the metasearch_regexp.

Unfortunately I have very much time these days, I hope someone will pick this fight :)

Member

elia commented Oct 10, 2013

Even better we could try to fix the metasearch mongoid builder. The code is inside aa-mongoid and should be straightforward.

https://github.com/elia/activeadmin-mongoid/blob/master/lib/meta_search/searches/mongoid.rb

The places to look at are the method_missing and the metasearch_regexp.

Unfortunately I have very much time these days, I hope someone will pick this fight :)

@david-boyd

This comment has been minimized.

Show comment Hide comment
@david-boyd

david-boyd Oct 11, 2013

Been able to debug a bit but got a little stuck,

It seems like the MongoidSearchBuilder.build() not used (thought that is where the fix would be)
The params passed into MongoidSearchBuilder.metasearch() by aa-data_access.rb apply_filtering() is nil.

This results in MongoidSearchBuilder.method_missing() always falling back to super and Mongoid doesn't respond_to() hasMany_id_eq method which is causing the issue.

Any suggestion on where to look next?

Been able to debug a bit but got a little stuck,

It seems like the MongoidSearchBuilder.build() not used (thought that is where the fix would be)
The params passed into MongoidSearchBuilder.metasearch() by aa-data_access.rb apply_filtering() is nil.

This results in MongoidSearchBuilder.method_missing() always falling back to super and Mongoid doesn't respond_to() hasMany_id_eq method which is causing the issue.

Any suggestion on where to look next?

@maxime-d

This comment has been minimized.

Show comment Hide comment
@maxime-d

maxime-d Nov 20, 2013

+1 same issue.

+1 same issue.

@boie0025 boie0025 closed this Jun 6, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment