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

drop support for InheritedResource #370

Merged
merged 2 commits into from
Dec 13, 2016

Conversation

coorasse
Copy link
Member

@coorasse coorasse commented Dec 11, 2016

…o feature/drop_support_for_inherited_resource

# Conflicts:
#	CHANGELOG.rdoc
@schmijos schmijos merged commit 0099999 into feature/v2 Dec 13, 2016
@schmijos schmijos deleted the feature/drop_support_for_inherited_resource branch December 13, 2016 09:47
@teohm
Copy link

teohm commented Jun 9, 2017

@coorasse @schmijos Hi, I noticed CanCanCan 2 has now dropped support for InheritedResource. We are still using InheritedResource together with CanCanCan in production. To upgrade to CanCanCan 2 and Rails 5, is there an available upgrade path for us?

@coorasse
Copy link
Member Author

coorasse commented Jul 9, 2017

no, sorry. we don't support it anymore. I suggest you to monkey patch cancancan in your project, even if this can tie you to old, unsupported, libraries even more.

@varyonic
Copy link

varyonic commented Dec 1, 2017

Just as an FYI inherited_resources was transferred to the activeadmin organization for continuing maintenance about a month after this PR was merged. New features are discouraged but Rails 5.2 is supported.

@TylerRick
Copy link

Hi @teohm, did you figure out a good upgrade path? I'm in a similar situation, upgrading to latest Rails and CanCanCan, only to discover that CanCanCan no longer works with InheritedResource (even though InheritedResource is still maintained and used).

I guess I'll try copying the code that was in earlier version of CanCanCan and see if it still works... 😞

@TylerRick
Copy link

Fortunately there wasn't a very big integration layer...

module CanCan
  module ControllerAdditions
    module ClassMethods
      def cancan_resource_class
        if ancestors.map(&:to_s).include? "InheritedResources::Actions"
          InheritedResource
        else
          ControllerResource
        end
      end
    end
  end
end

module CanCan
  class InheritedResource < ControllerResource
    def load_resource_instance
      if parent?
        @controller.send :association_chain
        @controller.instance_variable_get("@#{instance_name}")
      elsif new_actions.include? @params[:action].to_sym
        resource = @controller.send :build_resource
        assign_attributes(resource)
      else
        @controller.send :resource
      end
    end

    def resource_base
      @controller.send :end_of_association_chain
    end
  end
end

@coorasse
Copy link
Member Author

A new gem is welcome, I don't feel ike adding it back to the source code. It has been eliminated because the project was abandoned. Now the project is maintained again but they also suggest not to use it so...

@TylerRick
Copy link

I understand... :) A new gem is a good idea.

@TylerRick
Copy link

Here is one: https://rubygems.org/gems/cancan-inherited_resources

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

Successfully merging this pull request may close these issues.

5 participants