Activeadmin: undefined method `users_user_id_eq' for Ransack::Search<class: Detail, base: Grouping <combinator: and>>:Ransack::Search

Created on 14 Oct 2013  Â·  67Comments  Â·  Source: activeadmin/activeadmin

Error: undefined method `users_user_id_eq' for Ransack::Search>:Ransack::Search

Rails 4, Ruby 2. Latest version of Active Admin.

Added basic admin functionality to a model I have called Detail. Not sure what is going on or what info might be needed to troubleshoot the bug.

Thanks for any help.

bug filters

Most helpful comment

Ah, yeah we aren't correctly handling nested has_many :through relationships. For now, you can just remove that filter:

ActiveAdmin.register Detail do
  remove_filter :users
end

All 67 comments

Can you run this and report on the results?

ActiveAdmin.application.namespaces[:admin].resources[:Detail].filters

Sure you bet:

=> {:competitor_details=>{}, :competitors=>{}, :collections=>{}, :users=>{}, :authentications=>{}, :reports=>{}, :created_at=>{}, :updated_at=>{}, :params=>{}}

Hmm... and I assume you don't have any custom filters set up, and a Detail belongs_to a User?

The structure of that method (users_user_id_eq) reminds me of the has_many :through functionality added in #2541

I did at one point(In another admin .rb file) but took them out as I didn't need them any more.
Perhaps the relation is too complicated? Detail has many users..through competitors. Competitors has_many details through competitor details.. Competitor belongs_to a user.

ActiveAdmin.register Detail do
  menu :parent => "Models"

  index do
    column :id
    column :type
    column :created_at
    column :params
    actions
  end

end

class Detail < ActiveRecord::Base

  has_many :competitor_details, dependent: :destroy
  has_many :competitors, through: :competitor_details
  has_many :users, through: :competitors
  # ...
end

Ah, yeah we aren't correctly handling nested has_many :through relationships. For now, you can just remove that filter:

ActiveAdmin.register Detail do
  remove_filter :users
end

@shekibobo any idea on how to detect nested HMT associations?

@Daxter - Awesome. Thanks so much for the help; wasn't finding it from searching. That fixed the problem.

Well, it hid the problem :V

True.. :) Should I close or leave open for HMT?

Yeah definitely leave this open. We'll get this fixed.

Yeah this is gonna be a fun one. Might even get recursive.

Rough brainstorm on this:

reflection_chain = []
r = reflection
while r.through_reflection
  reflection_chain << r.through_reflection.name
  r = r.through_reflection
end
reflection_chain.reverse! << reflection.source_reflection.foreign_key
name = reflection_chain.join('_')

Search appears to work on the command line. Running through wwtd right now. I'll submit a pull request if it passes.

@perkins2099 Can you set the filter to filter :users, as: :check_boxes and tell me the error message, if any?

So, I've found a way to build this association chain, but I don't think Ransack supports nesting associations that deeply.

I have an association chain like so:

A has many B.
B has many C.
A has many C through B.

C has many D.
D has many E.
C has many E through D.

A has many E through C.

This is probably a terrible way to use through associations, but even so, I want to filter A by E. For a single through association, we would use the search method named:

Bs_C_id_eq

That is, the through association name, and the target association foreign key.

So in the case of filtering A by E, we would presumably follow this pattern:

Bs_Cs_Ds_E_id_eq

My first implementation would not support this, because the through associations don't exist between every association. We need to track the association chain all the way through.

TIL Reflection#chain :heart:

def input_name
  return method if seems_searchable?

  # Deal with has_many :through relationships in filters
  # If the relationship is a HMT, we set the search logic to be something
  # like :#{through_association}_#{end_association_id}.
  if through_association?
    chain = reflection.chain.slice(1..-1).reverse.map(&:name) << reflection.foreign_key
    name = chain.join('_')
  else
    name = method.to_s
    name.concat '_id' if reflection
  end
  name.concat multiple? ? '_in' : '_eq'
end

reflection.chain #=> [:Es, :Ds, :Cs, :Bs]
# we need to get rid of :Es and replace it with :E_id, then reverse it and join by '_'

The above code gives us the method chain I would think would work, but I still get an error message about the search method in my app.

Wondering if we can get some input from the good people on the Ransack team?

What's the error you get?

If it's too complicated, maybe we should just prevent nested HMT associations from being added to the default list of filters.

Might be the best bet. I get an error that the method I created, i.e. :bs_cs_ds_e_id_eq was not found. I believe it was a ransack error, but I'd have to double check, and I'm not at my computer right now. I did ping @radar on Twitter about the depth of association searches in Ransack, and am waiting to hear back from him. Might just be my assumption about how those search methods are formulated is wrong.

undefined method `bs_cs_ds_e_id_eq' for Ransack::Search<class: A, base: Grouping <combinator: and>>:Ransack::Search

@shekibobo - For the question regarding check boxes. I still get the error with those modifications

@perkins2099 Could you try my branch and see if it fixes your issue?

gem 'activeadmin', github: 'shekibobo/active_admin', branch: '2565-fix-nested-through-filters'

It looks like my assumption of being able to just chain association names together was flat out wrong, but now it's clear to me why. They work on a single has_many :through because the foreign key we are search on is an actual attribute of the direct association. So, just like we can search by :association_name_eq, we can search by :association_other_foreign_key_eq. So simple.

I'm good with switching back to the old concatenation method if you want. The chain method works nicely, but it might seem a bit too much like magic to someone down the road.

Seems like you all got it figured out before I came here. Glad :)

Yup. Thanks for checking it out, though!

@shekibobo - This branch works for me(Removed the remove_filter bits)! Thanks for the diligence.

@shekibobo - I tried your branch, still have a problem

Showing ~/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/active_admin-ec00dc24600a/app/views/active_admin/resource/index.html.arb where line #1 raised:

undefined method `patient_plan_patient_plan_id_eq' for Ransack::Search<class: Patient, base: Grouping <combinator: and>>:Ransack::Search

seems to be caused by a has_many through:

@bughit Can you show me how the patient plan relationship is defined?

@bughit Can you show me how you've defined the relationship for patient_plan? Can you also try using ref b9ab2507dff0bea743a1595ee880d13280425492?

gem 'activeadmin', github: 'shekibobo/active_admin', ref: 'b9ab2507dff0bea743a1595ee880d13280425492'

Let me know if that one works. Thanks.

b9ab2507dff0bea743a1595ee880d13280425492 is not working.

class Patient < User

  has_one :patient_plan, inverse_of: :patient, dependent: :destroy

  has_many :patient_plan_goals, through: :patient_plan

there's also another level of through nesting, has_many :patient_plan_goal_actions, through: :patient_plan_goals but it's the has_many in the previous post that's the current culprit

I guess I hadn't considered a has_one :through case. I'll take a look at this tonight.

not has_one through: although that's also possible and should work, but has_many through: :has_one_association

this is about the source: association of a through:, which I think can be nearly anything (has_one, has_many, belongs_to, and the through varieties, not sure about HABTM). I am guessing you tested only through: has_many

http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html

the docs don't seem to have an exhaustive list of possible source associations, I suppose the right thing would be to make sure that all possible supported combinations work with aa

@bughit I'm going to push up another branch to have you test.

gem 'activeadmin', github: 'shekibobo/active_admin', branch: 'test-through-has-one'

not sure if I was supposed to wait, but just tried it (revision: 5c9a27b3c7f86ee472d63f35f76ce21b647dc60d), still a problem

I can't get this to happen here. The basic setup for how we handle the has_* :through filtering is to grab all the associations, get rid of any that have a chain longer than 2, and then, if it's a through association, use the through association name and the foreign key for the end association.

What this suggests to me is that you have an association like so:

has_one :patient_plan
has_* :patient_plans, through: :patient_plan

PatientPlan should have a belongs_to :main_model and a belongs_to :patient_plan_goal

Wait.

Does your PatientPlan model look like this?

class PatientPlan < ActiveRecord::Base
  belongs_to :patient, inverse_of: :patient_plan
  has_many :patient_plan_goals
end

?

class PatientPlan < ActiveRecord::Base
  belongs_to :patient, inverse_of: :patient_plan

  has_many :patient_plan_goals, inverse_of: :patient_plan, dependent: :destroy

  has_many :patient_plan_goal_actions, through: :patient_plan_goals

end

Well that's the problem. The through model doesn't have the attribute for the joined model, thus can't be searched by ransack.

I found a fun method called ransackable_associations, but that doesn't actually seem to filter out the associations we're having troubles with.

@bughit I just pushed another one to my working branch. Could you try this one out if it passes travis?

gem 'activeadmin', github: 'shekibobo/active_admin', branch: '2565-fix-nested-through-filters'

yes, PatientPlan is not a join model, which should not be required, :through is a general purpose association forwarder.

Uncaught exception: ~/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/active_admin-b98df9ff9908/lib/active_admin/filters/formtastic_addons.rb:46: syntax error, unexpected tIDENTIFIER, expecting keyword_end
...ackable_attributes.include? ref.foreign_key if ref

Yeah, it's just that Ransack can't search through more than one associated model, and it can only search attributes on that single join model. At least so far as I understand the gem so far. So we just can't automatically build named filters for associations that don't follow the ransack-searchable patterns.

I think I fixed the parentheses issue in the error above (I think) if you want to try again. Hoping it passes travis this time.

working now, thanks

awesome!

Thanks for testing it out!

Okay, this should now be fixed on master :]

Can you confirm that the fix is still operational?

I have a has_many :through relationship that is showing the same issues as above.

@jufemaiz can you post the stack trace?

undefined method `measurement_data_id_eq' for #<Ransack::Search:0x000001a12124e0>

Hmmmm… Actually thinking more about it it's due to the lack _of_ an ID column on this particular table (timeseries data, odd import times etc). At this stage it's embedded within the prod db but I'm looking to migrate it out (off topic).

However the server does hang for considerable periods of time before coming back with that. I assume that the lack of ID column would be part of that problem?

@jufemaiz the hanging could be related to a bug in the latest release of Arbre. Using github: 'gregbell/arbre' might fix the hanging problem.

I'm seeing the same issue as @jufemaiz. I have a HMT relationship where the join table has no ID column. In my case, the model list has_many domains through list_domains, and list_domains has a primary key on [list_id,domain_id]. I'm trying to assign those associations using a nested has_many :list_domains under the list form in active admin, and I'm getting this error:

undefined method 'list_domains_id_eq' for Ransack::Search<class: List, base: Grouping <combinator: and>>:Ransack::Search

I experimented a little this morning with the issue I'm seeing. I was expecting the offending line to be the has_many in the ActiveAdmin register class, but that's not the case - commenting it out did nothing. If I comment out the has_many :list_domains line in my List model, ActiveAdmin functions normally. As soon as I uncomment that line, I get the error above.

I am also seeing this issue still, and have had to invoke remove_filter for all of my HABTM relationships.

# app.rb
class App < ActiveRecord::Base
  has_and_belongs_to_many :users
  belongs_to :account
  has_many :versions, class_name: 'AppVersion', dependent: :destroy
  has_many :secondary_tokens, dependent: :destroy
  has_many :apps, through: :secondary_tokens

  # business logic
end
# user.rb
class User < ActiveRecord::Base
  belongs_to :account
  has_many :devices, dependent: :destroy

  # This allows a user to see any apps that is provided via roles
  has_many :apps_provided_by_roles, source: :apps, through: :account_roles

  has_and_belongs_to_many :apps
  has_and_belongs_to_many :account_roles

  # business logic
end
# backtrace
Showing /vendor/bundler/bundler/gems/active_admin-cf3b1f70ab0e/app/views/active_admin/resource/index.html.arb where line #1 raised:

undefined method `apps_users_id_eq' for Ransack::Search<class: App, base: Grouping <combinator: and>>:Ransack::Search
Extracted source (around line #1):
1

  insert_tag renderer_for(:index)

Rails.root: REDACTED

Application Trace | Framework Trace | Full Trace
vendor/bundler/gems/ransack-1.2.3/lib/ransack/search.rb:86:in `method_missing'
vendor/bundler/gems/actionview-4.1.1/lib/action_view/helpers/tags/base.rb:28:in `value'
vendor/bundler/gems/actionview-4.1.1/lib/action_view/helpers/tags/select.rb:16:in `block in render'
vendor/bundler/gems/actionview-4.1.1/lib/action_view/helpers/tags/select.rb:16:in `fetch'
vendor/bundler/gems/actionview-4.1.1/lib/action_view/helpers/tags/select.rb:16:in `render'
vendor/bundler/gems/actionview-4.1.1/lib/action_view/helpers/form_options_helper.rb:165:in `select'
vendor/bundler/gems/actionview-4.1.1/lib/action_view/helpers/form_options_helper.rb:779:in `select'
vendor/bundler/gems/formtastic-2.3.0.rc3/lib/formtastic/inputs/select_input.rb:154:in `select_html'
vendor/bundler/gems/formtastic-2.3.0.rc3/lib/formtastic/inputs/select_input.rb:149:in `block in to_html'
vendor/bundler/gems/actionview-4.1.1/lib/action_view/helpers/capture_helper.rb:38:in `block in capture'
vendor/bundler/gems/actionview-4.1.1/lib/action_view/helpers/capture_helper.rb:200:in `with_output_buffer'
vendor/bundler/gems/haml-4.0.5/lib/haml/helpers/action_view_xss_mods.rb:5:in `with_output_buffer_with_haml_xss'
vendor/bundler/gems/actionview-4.1.1/lib/action_view/helpers/capture_helper.rb:38:in `capture'
vendor/bundler/gems/haml-4.0.5/lib/haml/helpers/action_view_mods.rb:52:in `capture_with_haml'
vendor/bundler/bundler/gems/active_admin-cf3b1f70ab0e/lib/active_admin/inputs/filter_base.rb:11:in `input_wrapping'
vendor/bundler/gems/formtastic-2.3.0.rc3/lib/formtastic/inputs/select_input.rb:146:in `to_html'
vendor/bundler/gems/formtastic-2.3.0.rc3/lib/formtastic/helpers/input_helper.rb:241:in `input'
vendor/bundler/bundler/gems/active_admin-cf3b1f70ab0e/lib/active_admin/form_builder.rb:26:in `block in input'
vendor/bundler/bundler/gems/active_admin-cf3b1f70ab0e/lib/active_admin/form_builder.rb:150:in `with_new_form_buffer'
vendor/bundler/bundler/gems/active_admin-cf3b1f70ab0e/lib/active_admin/form_builder.rb:26:in `input'
vendor/bundler/bundler/gems/active_admin-cf3b1f70ab0e/lib/active_admin/filters/forms.rb:16:in `filter'
vendor/bundler/bundler/gems/active_admin-cf3b1f70ab0e/lib/active_admin/filters/forms.rb:71:in `block (2 levels) in active_admin_filters_form_for'
vendor/bundler/bundler/gems/active_admin-cf3b1f70ab0e/lib/active_admin/filters/forms.rb:67:in `each'
vendor/bundler/bundler/gems/active_admin-cf3b1f70ab0e/lib/active_admin/filters/forms.rb:67:in `block in active_admin_filters_form_for'
vendor/bundler/gems/actionview-4.1.1/lib/action_view/helpers/capture_helper.rb:38:in `block in capture'
vendor/bundler/gems/actionview-4.1.1/lib/action_view/helpers/capture_helper.rb:200:in `with_output_buffer'
vendor/bundler/gems/haml-4.0.5/lib/haml/helpers/action_view_xss_mods.rb:5:in `with_output_buffer_with_haml_xss'
vendor/bundler/gems/actionview-4.1.1/lib/action_view/helpers/capture_helper.rb:38:in `capture'
vendor/bundler/gems/haml-4.0.5/lib/haml/helpers/action_view_mods.rb:52:in `capture_with_haml'
vendor/bundler/gems/actionview-4.1.1/lib/action_view/helpers/form_helper.rb:434:in `form_for'
vendor/bundler/gems/haml-4.0.5/lib/haml/helpers/action_view_mods.rb:139:in `form_for_with_haml'
vendor/bundler/gems/haml-4.0.5/lib/haml/helpers/action_view_xss_mods.rb:28:in `form_for_with_haml_xss'
vendor/bundler/bundler/gems/active_admin-cf3b1f70ab0e/lib/active_admin/filters/forms.rb:66:in `active_admin_filters_form_for'
vendor/bundler/gems/arbre-1.0.1/lib/arbre/element.rb:175:in `method_missing'
vendor/bundler/bundler/gems/active_admin-cf3b1f70ab0e/lib/active_admin/filters/resource_extension.rb:128:in `block in filters_sidebar_section'
vendor/bundler/bundler/gems/active_admin-cf3b1f70ab0e/lib/active_admin/views/components/sidebar_section.rb:20:in `instance_exec'
vendor/bundler/bundler/gems/active_admin-cf3b1f70ab0e/lib/active_admin/views/components/sidebar_section.rb:20:in `build_sidebar_content'
vendor/bundler/bundler/gems/active_admin-cf3b1f70ab0e/lib/active_admin/views/components/sidebar_section.rb:13:in `build'
vendor/bundler/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:30:in `block in build_tag'
vendor/bundler/gems/arbre-1.0.1/lib/arbre/context.rb:92:in `with_current_arbre_element'
vendor/bundler/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:49:in `with_current_arbre_element'
vendor/bundler/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:26:in `build_tag'
vendor/bundler/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:39:in `insert_tag'
vendor/bundler/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:14:in `sidebar_section'
vendor/bundler/bundler/gems/active_admin-cf3b1f70ab0e/lib/active_admin/views/pages/base.rb:122:in `block (2 levels) in build_sidebar'
vendor/bundler/bundler/gems/active_admin-cf3b1f70ab0e/lib/active_admin/views/pages/base.rb:121:in `collect'
vendor/bundler/bundler/gems/active_admin-cf3b1f70ab0e/lib/active_admin/views/pages/base.rb:121:in `block in build_sidebar'
vendor/bundler/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:31:in `block in build_tag'
vendor/bundler/gems/arbre-1.0.1/lib/arbre/context.rb:92:in `with_current_arbre_element'
vendor/bundler/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:49:in `with_current_arbre_element'
vendor/bundler/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:26:in `build_tag'
vendor/bundler/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:39:in `insert_tag'
vendor/bundler/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:14:in `div'
vendor/bundler/bundler/gems/active_admin-cf3b1f70ab0e/lib/active_admin/views/pages/base.rb:120:in `build_sidebar'
vendor/bundler/bundler/gems/active_admin-cf3b1f70ab0e/lib/active_admin/views/pages/base.rb:66:in `block in build_page_content'
vendor/bundler/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:31:in `block in build_tag'
vendor/bundler/gems/arbre-1.0.1/lib/arbre/context.rb:92:in `with_current_arbre_element'
vendor/bundler/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:49:in `with_current_arbre_element'
vendor/bundler/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:26:in `build_tag'
vendor/bundler/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:39:in `insert_tag'
vendor/bundler/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:14:in `div'
vendor/bundler/bundler/gems/active_admin-cf3b1f70ab0e/lib/active_admin/views/pages/base.rb:64:in `build_page_content'
vendor/bundler/bundler/gems/active_admin-cf3b1f70ab0e/lib/active_admin/views/pages/base.rb:47:in `block (2 levels) in build_page'
vendor/bundler/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:31:in `block in build_tag'
vendor/bundler/gems/arbre-1.0.1/lib/arbre/context.rb:92:in `with_current_arbre_element'
vendor/bundler/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:49:in `with_current_arbre_element'
vendor/bundler/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:26:in `build_tag'
vendor/bundler/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:39:in `insert_tag'
vendor/bundler/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:14:in `div'
vendor/bundler/bundler/gems/active_admin-cf3b1f70ab0e/lib/active_admin/views/pages/base.rb:44:in `block in build_page'
vendor/bundler/gems/arbre-1.0.1/lib/arbre/context.rb:92:in `with_current_arbre_element'
vendor/bundler/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:49:in `with_current_arbre_element'
vendor/bundler/bundler/gems/active_admin-cf3b1f70ab0e/lib/active_admin/views/pages/base.rb:43:in `build_page'
vendor/bundler/bundler/gems/active_admin-cf3b1f70ab0e/lib/active_admin/views/pages/base.rb:10:in `build'
vendor/bundler/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:30:in `block in build_tag'
vendor/bundler/gems/arbre-1.0.1/lib/arbre/context.rb:92:in `with_current_arbre_element'
vendor/bundler/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:26:in `build_tag'
vendor/bundler/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:39:in `insert_tag'
vendor/bundler/bundler/gems/active_admin-cf3b1f70ab0e/app/views/active_admin/resource/index.html.arb:1:in `block in _vendor_bundler_bundler_gems_active_admin_cf_b_f__ab_e_app_views_active_admin_resource_index_html_arb__9397484507466979_70309021550460'
vendor/bundler/gems/arbre-1.0.1/lib/arbre/context.rb:45:in `instance_eval'
vendor/bundler/gems/arbre-1.0.1/lib/arbre/context.rb:45:in `initialize'
vendor/bundler/bundler/gems/active_admin-cf3b1f70ab0e/app/views/active_admin/resource/index.html.arb:1:in `new'
vendor/bundler/bundler/gems/active_admin-cf3b1f70ab0e/app/views/active_admin/resource/index.html.arb:1:in `_vendor_bundler_bundler_gems_active_admin_cf_b_f__ab_e_app_views_active_admin_resource_index_html_arb__9397484507466979_70309021550460'
vendor/bundler/gems/actionview-4.1.1/lib/action_view/template.rb:145:in `block in render'
vendor/bundler/gems/activesupport-4.1.1/lib/active_support/notifications.rb:161:in `instrument'
vendor/bundler/gems/actionview-4.1.1/lib/action_view/template.rb:339:in `instrument'
vendor/bundler/gems/actionview-4.1.1/lib/action_view/template.rb:143:in `render'
vendor/bundler/gems/actionview-4.1.1/lib/action_view/renderer/template_renderer.rb:55:in `block (2 levels) in render_template'
vendor/bundler/gems/actionview-4.1.1/lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
vendor/bundler/gems/activesupport-4.1.1/lib/active_support/notifications.rb:159:in `block in instrument'
vendor/bundler/gems/activesupport-4.1.1/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
vendor/bundler/gems/activesupport-4.1.1/lib/active_support/notifications.rb:159:in `instrument'
vendor/bundler/gems/actionview-4.1.1/lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
vendor/bundler/gems/actionview-4.1.1/lib/action_view/renderer/template_renderer.rb:54:in `block in render_template'
vendor/bundler/gems/actionview-4.1.1/lib/action_view/renderer/template_renderer.rb:62:in `render_with_layout'
vendor/bundler/gems/actionview-4.1.1/lib/action_view/renderer/template_renderer.rb:53:in `render_template'
vendor/bundler/gems/actionview-4.1.1/lib/action_view/renderer/template_renderer.rb:17:in `render'
vendor/bundler/gems/actionview-4.1.1/lib/action_view/renderer/renderer.rb:42:in `render_template'
vendor/bundler/gems/actionview-4.1.1/lib/action_view/renderer/renderer.rb:23:in `render'
vendor/bundler/gems/actionview-4.1.1/lib/action_view/rendering.rb:99:in `_render_template'
vendor/bundler/gems/actionpack-4.1.1/lib/action_controller/metal/streaming.rb:217:in `_render_template'
vendor/bundler/gems/actionview-4.1.1/lib/action_view/rendering.rb:82:in `render_to_body'
vendor/bundler/gems/actionpack-4.1.1/lib/action_controller/metal/rendering.rb:32:in `render_to_body'
vendor/bundler/gems/actionpack-4.1.1/lib/action_controller/metal/renderers.rb:32:in `render_to_body'
vendor/bundler/gems/actionpack-4.1.1/lib/abstract_controller/rendering.rb:25:in `render'
vendor/bundler/gems/actionpack-4.1.1/lib/action_controller/metal/rendering.rb:16:in `render'
vendor/bundler/gems/actionpack-4.1.1/lib/action_controller/metal/instrumentation.rb:41:in `block (2 levels) in render'
vendor/bundler/gems/activesupport-4.1.1/lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
~/.rbenv/versions/2.1.1/lib/ruby/2.1.0/benchmark.rb:294:in `realtime'
vendor/bundler/gems/activesupport-4.1.1/lib/active_support/core_ext/benchmark.rb:12:in `ms'
vendor/bundler/gems/actionpack-4.1.1/lib/action_controller/metal/instrumentation.rb:41:in `block in render'
vendor/bundler/gems/actionpack-4.1.1/lib/action_controller/metal/instrumentation.rb:84:in `cleanup_view_runtime'
vendor/bundler/gems/activerecord-4.1.1/lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
vendor/bundler/gems/actionpack-4.1.1/lib/action_controller/metal/instrumentation.rb:40:in `render'
vendor/bundler/gems/actionpack-4.1.1/lib/action_controller/metal/implicit_render.rb:10:in `default_render'
vendor/bundler/gems/actionpack-4.1.1/lib/action_controller/metal/responder.rb:238:in `default_render'
vendor/bundler/gems/actionpack-4.1.1/lib/action_controller/metal/responder.rb:165:in `to_html'
vendor/bundler/gems/responders-1.0.0/lib/responders/flash_responder.rb:104:in `to_html'
vendor/bundler/gems/actionpack-4.1.1/lib/action_controller/metal/responder.rb:158:in `respond'
vendor/bundler/gems/actionpack-4.1.1/lib/action_controller/metal/responder.rb:151:in `call'
vendor/bundler/gems/actionpack-4.1.1/lib/action_controller/metal/mime_responds.rb:400:in `respond_with'
vendor/bundler/gems/inherited_resources-1.4.1/lib/inherited_resources/actions.rb:7:in `index'
vendor/bundler/gems/actionpack-4.1.1/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
vendor/bundler/gems/actionpack-4.1.1/lib/abstract_controller/base.rb:189:in `process_action'
vendor/bundler/gems/actionpack-4.1.1/lib/action_controller/metal/rendering.rb:10:in `process_action'
vendor/bundler/gems/actionpack-4.1.1/lib/abstract_controller/callbacks.rb:20:in `block in process_action'
vendor/bundler/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:113:in `call'
vendor/bundler/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:113:in `call'
vendor/bundler/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:166:in `block in halting'
vendor/bundler/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:166:in `call'
vendor/bundler/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:166:in `block in halting'
vendor/bundler/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:166:in `call'
vendor/bundler/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:166:in `block in halting'
vendor/bundler/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:229:in `call'
vendor/bundler/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:229:in `block in halting'
vendor/bundler/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:229:in `call'
vendor/bundler/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:229:in `block in halting'
vendor/bundler/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:166:in `call'
vendor/bundler/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:166:in `block in halting'
vendor/bundler/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:166:in `call'
vendor/bundler/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:166:in `block in halting'
vendor/bundler/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:166:in `call'
vendor/bundler/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:166:in `block in halting'
vendor/bundler/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:86:in `call'
vendor/bundler/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:86:in `run_callbacks'
vendor/bundler/gems/actionpack-4.1.1/lib/abstract_controller/callbacks.rb:19:in `process_action'
vendor/bundler/gems/actionpack-4.1.1/lib/action_controller/metal/rescue.rb:29:in `process_action'
vendor/bundler/gems/actionpack-4.1.1/lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
vendor/bundler/gems/activesupport-4.1.1/lib/active_support/notifications.rb:159:in `block in instrument'
vendor/bundler/gems/activesupport-4.1.1/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
vendor/bundler/gems/activesupport-4.1.1/lib/active_support/notifications.rb:159:in `instrument'
vendor/bundler/gems/actionpack-4.1.1/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
vendor/bundler/gems/actionpack-4.1.1/lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
vendor/bundler/gems/activerecord-4.1.1/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
vendor/bundler/gems/actionpack-4.1.1/lib/abstract_controller/base.rb:136:in `process'
vendor/bundler/gems/actionview-4.1.1/lib/action_view/rendering.rb:30:in `process'
vendor/bundler/gems/actionpack-4.1.1/lib/action_controller/metal.rb:195:in `dispatch'
vendor/bundler/gems/actionpack-4.1.1/lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
vendor/bundler/gems/actionpack-4.1.1/lib/action_controller/metal.rb:231:in `block in action'
vendor/bundler/gems/actionpack-4.1.1/lib/action_dispatch/routing/route_set.rb:80:in `call'
vendor/bundler/gems/actionpack-4.1.1/lib/action_dispatch/routing/route_set.rb:80:in `dispatch'
vendor/bundler/gems/actionpack-4.1.1/lib/action_dispatch/routing/route_set.rb:48:in `call'
vendor/bundler/gems/actionpack-4.1.1/lib/action_dispatch/journey/router.rb:71:in `block in call'
vendor/bundler/gems/actionpack-4.1.1/lib/action_dispatch/journey/router.rb:59:in `each'
vendor/bundler/gems/actionpack-4.1.1/lib/action_dispatch/journey/router.rb:59:in `call'
vendor/bundler/gems/actionpack-4.1.1/lib/action_dispatch/routing/route_set.rb:676:in `call'
vendor/bundler/gems/omniauth-1.2.1/lib/omniauth/strategy.rb:186:in `call!'
vendor/bundler/gems/omniauth-1.2.1/lib/omniauth/strategy.rb:164:in `call'
vendor/bundler/gems/omniauth-1.2.1/lib/omniauth/builder.rb:59:in `call'
vendor/bundler/gems/warden-1.2.3/lib/warden/manager.rb:35:in `block in call'
vendor/bundler/gems/warden-1.2.3/lib/warden/manager.rb:34:in `catch'
vendor/bundler/gems/warden-1.2.3/lib/warden/manager.rb:34:in `call'
vendor/bundler/gems/rack-1.5.2/lib/rack/etag.rb:23:in `call'
vendor/bundler/gems/rack-1.5.2/lib/rack/conditionalget.rb:25:in `call'
vendor/bundler/gems/rack-1.5.2/lib/rack/head.rb:11:in `call'
vendor/bundler/gems/actionpack-4.1.1/lib/action_dispatch/middleware/params_parser.rb:27:in `call'
vendor/bundler/gems/actionpack-4.1.1/lib/action_dispatch/middleware/flash.rb:254:in `call'
vendor/bundler/gems/rack-1.5.2/lib/rack/session/abstract/id.rb:225:in `context'
vendor/bundler/gems/rack-1.5.2/lib/rack/session/abstract/id.rb:220:in `call'
vendor/bundler/gems/actionpack-4.1.1/lib/action_dispatch/middleware/cookies.rb:560:in `call'
vendor/bundler/gems/activerecord-4.1.1/lib/active_record/query_cache.rb:36:in `call'
vendor/bundler/gems/activerecord-4.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call'
vendor/bundler/gems/activerecord-4.1.1/lib/active_record/migration.rb:380:in `call'
vendor/bundler/gems/actionpack-4.1.1/lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
vendor/bundler/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:82:in `run_callbacks'
vendor/bundler/gems/actionpack-4.1.1/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
vendor/bundler/gems/actionpack-4.1.1/lib/action_dispatch/middleware/reloader.rb:73:in `call'
vendor/bundler/gems/actionpack-4.1.1/lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
vendor/bundler/gems/actionpack-4.1.1/lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
vendor/bundler/gems/actionpack-4.1.1/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
vendor/bundler/gems/railties-4.1.1/lib/rails/rack/logger.rb:38:in `call_app'
vendor/bundler/gems/railties-4.1.1/lib/rails/rack/logger.rb:20:in `block in call'
vendor/bundler/gems/activesupport-4.1.1/lib/active_support/tagged_logging.rb:68:in `block in tagged'
vendor/bundler/gems/activesupport-4.1.1/lib/active_support/tagged_logging.rb:26:in `tagged'
vendor/bundler/gems/activesupport-4.1.1/lib/active_support/tagged_logging.rb:68:in `tagged'
vendor/bundler/gems/railties-4.1.1/lib/rails/rack/logger.rb:20:in `call'
vendor/bundler/gems/quiet_assets-1.0.2/lib/quiet_assets.rb:18:in `call_with_quiet_assets'
vendor/bundler/gems/actionpack-4.1.1/lib/action_dispatch/middleware/request_id.rb:21:in `call'
vendor/bundler/gems/rack-1.5.2/lib/rack/methodoverride.rb:21:in `call'
vendor/bundler/gems/rack-1.5.2/lib/rack/runtime.rb:17:in `call'
vendor/bundler/gems/activesupport-4.1.1/lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
vendor/bundler/gems/rack-1.5.2/lib/rack/lock.rb:17:in `call'
vendor/bundler/gems/actionpack-4.1.1/lib/action_dispatch/middleware/static.rb:64:in `call'
vendor/bundler/gems/rack-1.5.2/lib/rack/sendfile.rb:112:in `call'
vendor/bundler/gems/railties-4.1.1/lib/rails/engine.rb:514:in `call'
vendor/bundler/gems/railties-4.1.1/lib/rails/application.rb:144:in `call'
vendor/bundler/gems/rack-1.5.2/lib/rack/lock.rb:17:in `call'
vendor/bundler/gems/rack-1.5.2/lib/rack/content_length.rb:14:in `call'
vendor/bundler/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in `service'
~/.rbenv/versions/2.1.1/lib/ruby/2.1.0/webrick/httpserver.rb:138:in `service'
~/.rbenv/versions/2.1.1/lib/ruby/2.1.0/webrick/httpserver.rb:94:in `run'
~/.rbenv/versions/2.1.1/lib/ruby/2.1.0/webrick/server.rb:295:in `block in start_thread'
vendor/bundler/gems/logging-1.8.2/lib/logging/diagnostic_context.rb:323:in `call'
vendor/bundler/gems/logging-1.8.2/lib/logging/diagnostic_context.rb:323:in `block in create_with_logging_context'

@Lordnibbler same problem =(

+1 for this. I'm having the same problem.

Same probleme here.

# movie_option.rb
class MovieOption < ActiveRecord::Base
  has_and_belongs_to_many :movies
end
# movie.rb
class Movie < ActiveRecord::Base
  has_and_belongs_to_many :options, class_name: 'MovieOption'
  #...
end
# error
undefined method `movies_options_id_eq' for Ransack::Search<class: Movie, base: Grouping <combinator: and>>:Ransack::Search

@dgellow just a dumb question, but could you possibly go with the following to move away from a HABTM approach?

# movie.rb
class Movie < ActiveRecord::Base
  has_many :movie_options
  has_many :options, through: :movie_options
  #...
end
# option.rb
class Option < ActiveRecord::Base
  has_many :movie_options
  has_many :movies, through: :movie_options
  #...
end
# movie_option.rb
class MovieOption < ActiveRecord::Base
  belongs_to :movie
  belongs_to :options
  #...
end

And then leave in the ID column in the movie_options table? This would ensure that the id_eq responds correctly, and also allow you to add any additional metadata you'd like to the movie_option entry that joins the two entries.

I am having the same problem with a HABTM. Any news on that?

+1 - having the same issue with HABTM relationships. For every model that has one, rendering the page fails.

+1 also having same problem on gem 'activeadmin', github: 'gregbell/active_admin'

look like the problem is appear only with rails-4.1.1, versions rails-4.0.8 and rails 4.1.2+ work fine for me. Using ransack-1.2.3

difference between result ActiveAdmin.application.namespaces[:admin].resources[:Profile].filters

4.0.8

{:profiles_items=>{}, :items=>{}, :slug=>{}, :first_name=>{}, :last_name=>{}, :completed=>{}, :created_at=>{}, :updated_at=>{}}

4.1.1:

{:items=>{}, :slug=>{}, :first_name=>{}, :last_name=>{}, :completed=>{}, :created_at=>{}, :updated_at=>{}}

look like "profiles_items" is excess
and useful hack for version 4.1.1 is:

# in resource code
config.filters.each {|name,value| remove_filter(name) if name.match /#{config.resource_table_name.gsub('"','')}_*/ }

P.S with rails 4.1.2-4.1.4 active_admin filters work fine, but thinking_sphinx have a problem with HABTM relations

Hi there Greg. I saw the problem in Rails 4.0.5

What was the version of Ransack::Search in the two above instances?

On 6 July 2014 18:26, wild [email protected] wrote:

look like the problem is appear only with rails-4.1.1, versions
rails-4.0.8 and rails 4.1.2+ work fine for me.

difference between result
ActiveAdmin.application.namespaces[:admin].resources[:Profile].filters

4.0.8

{:profiles_items=>{}, :items=>{}, :slug=>{}, :first_name=>{}, :last_name=>{}, :completed=>{}, :created_at=>{}, :updated_at=>{}}

4.1.1:

{:items=>{}, :slug=>{}, :first_name=>{}, :last_name=>{}, :completed=>{}, :created_at=>{}, :updated_at=>{}}

look like "profiles_items" is excess
and useful hack for version 4.1.1 is:

in resource codeconfig.filters.each {|name,value| remove_filter(name) if name.match /#{config.resource_table_name.gsub('"','')}_*/ }

P.S with rails 4.1.2-4.1.4 _active_admin_ filters work fine, but
_thinking_sphinx_ have a problem with HABTM relations

—
Reply to this email directly or view it on GitHub
https://github.com/gregbell/active_admin/issues/2565#issuecomment-48105957
.


Joel Courtney
m: +61 401 501 625
e: [email protected]
w: http://euphemize.net
p: http://flic.kr/jufemaiz/

t: http://twitter.com/jufemaiz

Same problem here as of revision 27360996837146ebbbf3b3597049b1586542fbeb with rails 4.1.4. Did a workaround as specified on https://github.com/gregbell/active_admin/issues/2565#issuecomment-26229344

I'm also running into this. Is anyone working on a fix? Looks like it will be included in 1.0.0. Is that correct and if so when will that become available? Looks like its 5 months past due.

BTW - I don't know if any of you have stumbled on to this before but just defining the filter fixes the problem. Just found that out by experimenting more.

Hi,

Thanks in advance for any help. I am getting an error when using active admin in my 'rails 4.1.4' application. This model does not have any associations. Has anyone encountered this before? Thanks again!

Error:
NoMethodError at /admin/time_tables
undefined method `w_day_start' for #Ransack::Search:0x00000008fcbc70

Model:
class TimeTable < ActiveRecord::Base
end

Schema:
create_table "time_tables", force: true do |t|
t.string "name"
t.datetime "w_day_start"
t.datetime "w_day_stop"
t.datetime "w_end_start"
t.datetime "w_end_stop"
t.text "note"
t.datetime "created_at"
t.datetime "updated_at"
end

@tmclark737 ActiveAdmin / Ransack have a problem with columns that ends with start. You can try to disable all filters or the filters for the fields with start.

If that doesn't work, please open a new issue, I think that is not related to this one.

timoschilling! Thanks for the quick reply! I will try it out right now.

Can someone that has this problem, please check that is still exists, with current ransack master?

@tmclark737 ActiveAdmin should now work with filters that ends with start

Sweet! Thanks Timo. =)

On Thu, Nov 13, 2014 at 4:11 PM, Timo Schilling [email protected]
wrote:

@tmclark737 https://github.com/tmclark737 ActiveAdmin should now work
with filters that ends with start

Reply to this email directly or view it on GitHub
https://github.com/activeadmin/activeadmin/issues/2565#issuecomment-62990393
.

_Ty Clark PE_
Bay Efficiency, LLC
Phone: (415) 730-2710
Email: Ty.[email protected]
http://www.linkedin.com/in/clarkty

Ransack had some problems in the past, wich ends in error like:

undefined method `users_user_id_eq' for Ransack::Search<class: Detail, base: Grouping <combinator: and>>:Ransack::Search

While here is no activity since a while, I'm going to close this.

If someone has problems like this please open a new issue

thanks u @seanlinsley

Was this page helpful?
0 / 5 - 0 ratings

Related issues

simontol picture simontol  Â·  28Comments

releu picture releu  Â·  50Comments

rainchen picture rainchen  Â·  32Comments

seanlinsley picture seanlinsley  Â·  31Comments

seanlinsley picture seanlinsley  Â·  46Comments