Skip to content
This repository

Support Inherited Resources >= 1.3.1 #1183

Closed
pcreux opened this Issue March 27, 2012 · 6 comments

5 participants

Philippe Creux jeff ancel Drew Ulmer Chad Boyd Artur Trofimov
Philippe Creux
Collaborator

Inherited Resources 1.3.1 does not provide flash messages anymore. It would be great to implement those to support any version of Inherited Resources.

Drew Ulmer
Collaborator

I have a feeling this is related to some of the work on the related responders gem. Inherited Resources uses responders to handle flash messages and there are a number of commits related to flash messages lately. Perhaps we could explore brokenness by breaking down which versions of responders we are seeing this bad behavior with. Also @pcreux I think you mean 1.3.1 in the issue title, not 0.3.1.

jeff ancel
Collaborator
Drew Ulmer
Collaborator

If it helps at all, I upgraded my app to activeadmin 0.4.3 and inherited_resources 1.3.1 with responders 0.9.1 yesterday and I do see flash messages. I also updated to Rails 3.2.2 at the same time though I don't think that'd be related to this issue.

Philippe Creux
Collaborator

It looks like this was a bug with responders 0.9.0. It is now fixed in 0.9.1. See plataformatec/responders#39

If this is true, we can just revert aaef600 :)

Chad Boyd

Yes, please do revert this, or increase to version 1.3.1. This change also breaks redirection on create action with a nested polymorphic optional resource:

app/admin/credit_card_transactions.rb:

ActiveAdmin.register CreditCardTransaction do
    controller.belongs_to :customer, :franchise, polymorphic: true
end

config/routes.rb:

MyApp::Application.routes.draw do
  ActiveAdmin.routes(self)

  resources :customers do
    resources :credit_card_transactions
  end

  resources :franchises do
    resources :credit_card_transactions
  end
end

I haven't tracked down why yet, but if I stop using AA master and go back to 0.4.3, which allowed me to use IR 1.3.1 the problem goes away.

Specifically, when POSTing to this:

/customers/15/credit_card_transactions

I get redirected to this:

/credit_card_transactions/87

I expect to get redirected to:

/customers/15/credit_card_transactions/87

This works as expected with IR 1.3.1, but not with IR 1.3.0.

jeff ancel jancel closed this in 828f771 April 22, 2012
Artur Trofimov

It is good feature. But if you have renamed resource, it's fail.

In my project I have:

ActiveAdmin.register User::Vendor, :as => "Activity Partner" do

in discounts.rb:

ActiveAdmin.register Discount do
  controller.belongs_to :program, :activity_partner, polymorphic: true
...

and whet I go to http://localhost:3000/admin/activity_partners/32/discounts/ (for example) I see:

NoMethodError in Admin::DiscountsController#index
undefined method `find' for nil:NilClass

In logs:

NoMethodError (undefined method `find' for nil:NilClass):
  inherited_resources (1.3.1) lib/inherited_resources/belongs_to_helpers.rb:83:in `evaluate_parent'
  inherited_resources (1.3.1) lib/inherited_resources/base_helpers.rb:131:in `block in association_chain'
  inherited_resources (1.3.1) lib/inherited_resources/base_helpers.rb:130:in `each'
  inherited_resources (1.3.1) lib/inherited_resources/base_helpers.rb:130:in `inject'
  inherited_resources (1.3.1) lib/inherited_resources/base_helpers.rb:130:in `association_chain'
  inherited_resources (1.3.1) lib/inherited_resources/base_helpers.rb:169:in `end_of_association_chain'
  activeadmin (0.5.0) lib/active_admin/resource_controller/collection.rb:31:in `scoped_collection'
  activeadmin (0.5.0) lib/active_admin/resource_controller/collection.rb:17:in `active_admin_collection'
  activeadmin (0.5.0) lib/active_admin/resource_controller/collection.rb:40:in `active_admin_collection'
  activeadmin (0.5.0) lib/active_admin/resource_controller/collection.rb:64:in `active_admin_collection'
  activeadmin (0.5.0) lib/active_admin/resource_controller/collection.rb:87:in `active_admin_collection'
  activeadmin (0.5.0) lib/active_admin/resource_controller/collection.rb:121:in `active_admin_collection'
  activeadmin (0.5.0) lib/active_admin/resource_controller/collection.rb:13:in `collection'
  inherited_resources (1.3.1) lib/inherited_resources/actions.rb:7:in `index'
  activeadmin (0.5.0) lib/active_admin/resource_controller/actions.rb:11:in `index'
  actionpack (3.2.8) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
  actionpack (3.2.8) lib/abstract_controller/base.rb:167:in `process_action'
  actionpack (3.2.8) lib/action_controller/metal/rendering.rb:10:in `process_action'
  actionpack (3.2.8) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
  activesupport (3.2.8) lib/active_support/callbacks.rb:469:in `_run__3133481713414174068__process_action__2871937794258096447__callbacks'
  activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `__run_callback'
  activesupport (3.2.8) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
  activesupport (3.2.8) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (3.2.8) lib/abstract_controller/callbacks.rb:17:in `process_action'
  actionpack (3.2.8) lib/action_controller/metal/rescue.rb:29:in `process_action'
  actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
  activesupport (3.2.8) lib/active_support/notifications.rb:123:in `block in instrument'
  activesupport (3.2.8) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (3.2.8) lib/active_support/notifications.rb:123:in `instrument'
  actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
  actionpack (3.2.8) lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
  activerecord (3.2.8) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
  actionpack (3.2.8) lib/abstract_controller/base.rb:121:in `process'
  actionpack (3.2.8) lib/abstract_controller/rendering.rb:45:in `process'
  actionpack (3.2.8) lib/action_controller/metal.rb:203:in `dispatch'
  actionpack (3.2.8) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
  actionpack (3.2.8) lib/action_controller/metal.rb:246:in `block in action'
  actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:73:in `call'
  actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
  actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:36:in `call'
  journey (1.0.4) lib/journey/router.rb:68:in `block in call'
  journey (1.0.4) lib/journey/router.rb:56:in `each'
  journey (1.0.4) lib/journey/router.rb:56:in `call'
  actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:600:in `call'
  rack-raw-upload (1.1.0) lib/rack/raw_upload.rb:17:in `call'
  omniauth (1.1.1) lib/omniauth/strategy.rb:177:in `call!'
  omniauth (1.1.1) lib/omniauth/strategy.rb:157:in `call'
  omniauth (1.1.1) lib/omniauth/strategy.rb:177:in `call!'
  omniauth (1.1.1) lib/omniauth/strategy.rb:157:in `call'
  bullet (4.1.6) lib/bullet/rack.rb:11:in `call'
  sass (3.2.1) lib/sass/plugin/rack.rb:54:in `call'
  warden (1.2.1) lib/warden/manager.rb:35:in `block in call'
  warden (1.2.1) lib/warden/manager.rb:34:in `catch'
  warden (1.2.1) lib/warden/manager.rb:34:in `call'
  actionpack (3.2.8) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
  rack (1.4.1) lib/rack/etag.rb:23:in `call'
  rack (1.4.1) lib/rack/conditionalget.rb:25:in `call'
  actionpack (3.2.8) lib/action_dispatch/middleware/head.rb:14:in `call'
  actionpack (3.2.8) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
  actionpack (3.2.8) lib/action_dispatch/middleware/flash.rb:242:in `call'
  rack (1.4.1) lib/rack/session/abstract/id.rb:205:in `context'
  rack (1.4.1) lib/rack/session/abstract/id.rb:200:in `call'
  actionpack (3.2.8) lib/action_dispatch/middleware/cookies.rb:339:in `call'
  activerecord (3.2.8) lib/active_record/query_cache.rb:64:in `call'
  activerecord (3.2.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:473:in `call'
  actionpack (3.2.8) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
  activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `_run__860180535922513811__call__3454528873148901651__callbacks'
  activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `__run_callback'
  activesupport (3.2.8) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
  activesupport (3.2.8) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (3.2.8) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  actionpack (3.2.8) lib/action_dispatch/middleware/reloader.rb:65:in `call'
  actionpack (3.2.8) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
  actionpack (3.2.8) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
  actionpack (3.2.8) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
  railties (3.2.8) lib/rails/rack/logger.rb:26:in `call_app'
  railties (3.2.8) lib/rails/rack/logger.rb:16:in `call'
  actionpack (3.2.8) lib/action_dispatch/middleware/request_id.rb:22:in `call'
  rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
  rack (1.4.1) lib/rack/runtime.rb:17:in `call'
  activesupport (3.2.8) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
  rack (1.4.1) lib/rack/lock.rb:15:in `call'
  actionpack (3.2.8) lib/action_dispatch/middleware/static.rb:62:in `call'
  railties (3.2.8) lib/rails/engine.rb:479:in `call'
  railties (3.2.8) lib/rails/application.rb:223:in `call'
  rack (1.4.1) lib/rack/content_length.rb:14:in `call'
  railties (3.2.8) lib/rails/rack/log_tailer.rb:17:in `call'
  rack (1.4.1) lib/rack/handler/webrick.rb:59:in `service'
  /home/artur/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
  /home/artur/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
  /home/artur/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'

I see that problem is in inherited_resources, but how can I solve this problem without model renaming (It is important that the menu display vendors as activity partners)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.