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

Don't generate helper methods when resource's name is Resource #318

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
2 participants
@ka8725
Contributor

ka8725 commented Sep 18, 2013

I have troubles when I inherit ResourcesController from InheritedResources::Base: I try to use resource_path or edit_resource_path but application gets infinitive recursion and as a result I have exception:

SystemStackError - stack level too deep:
  (gem) activesupport-3.2.12/lib/active_support/core_ext/array/extract_options.rb:23:in `'

So I see here only one solution - don't define helper methods when resource's class name is "Resource". This fix is about it

@avsej

This comment has been minimized.

Show comment
Hide comment
@avsej

avsej Sep 18, 2013

Do not use Resource to name your resources

avsej commented Sep 18, 2013

Do not use Resource to name your resources

@ka8725

This comment has been minimized.

Show comment
Hide comment
@ka8725

ka8725 Sep 18, 2013

Contributor

Rails doesn't prohibit to name model with Resource. The gem is extension for rails, so it should not break rails conventions

Contributor

ka8725 commented Sep 18, 2013

Rails doesn't prohibit to name model with Resource. The gem is extension for rails, so it should not break rails conventions

@avsej

This comment has been minimized.

Show comment
Hide comment
@avsej

avsej Sep 18, 2013

all correct. see definition of SHOULD
http://www.ietf.org/rfc/rfc2119.txt

SHOULD This word, or the adjective "RECOMMENDED", mean that there
may exist valid reasons in particular circumstances to ignore a
particular item, but the full implications must be understood and
carefully weighed before choosing a different course.

avsej commented Sep 18, 2013

all correct. see definition of SHOULD
http://www.ietf.org/rfc/rfc2119.txt

SHOULD This word, or the adjective "RECOMMENDED", mean that there
may exist valid reasons in particular circumstances to ignore a
particular item, but the full implications must be understood and
carefully weighed before choosing a different course.

@ka8725

This comment has been minimized.

Show comment
Hide comment
@ka8725

ka8725 Nov 12, 2013

Contributor

Ok, I see that this problem can be fixed with removing method. It means that if you have collision like this you always can delete generated helper methods from the controller:

class ResourcesController < InheritedResources::Base
  # HACK: delete generated method by inherited resources.
  # It needs to use real generated method for actual resource
  remove_method :resource_path
end

So it's not necessary to change inherited_resources code

Contributor

ka8725 commented Nov 12, 2013

Ok, I see that this problem can be fixed with removing method. It means that if you have collision like this you always can delete generated helper methods from the controller:

class ResourcesController < InheritedResources::Base
  # HACK: delete generated method by inherited resources.
  # It needs to use real generated method for actual resource
  remove_method :resource_path
end

So it's not necessary to change inherited_resources code

@ka8725 ka8725 closed this Nov 12, 2013

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