Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Fix url helpers on mountable engines #191

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
7 participants
Contributor

juniorz commented Dec 27, 2011

Original pull request: josevalim#186 by @marcelloma

Changed to trust on a public API instead a obscure method (_railtie) and verifies if the engine has an isolated namespace.

@josevalim josevalim commented on the diff Dec 27, 2011

lib/inherited_resources/class_methods.rb
@@ -338,6 +338,16 @@ def initialize_resources_class_accessors! #:nodoc:
# Deal with namespaced controllers
namespaces = self.controller_path.split('/')[0..-2]
+
+ # Remove namespace if its a mountable engine
+ namespaces.delete_if do |namespace|
@josevalim

josevalim Dec 27, 2011

Contributor

I believe the best way to achieve this is to simply do it as Rails:

https://github.com/rails/rails/blob/master/activemodel/lib/active_model/naming.rb#L91

Something like this:

namespaces = self.parents
self.parents.delete_if do |n|
    n.respond_to?(:use_relative_model_naming?) && n.use_relative_model_naming?
end
namespaces.map!(&:underscore)

It will work only on 3.2 though but I believe this is fine.

knewter commented Feb 11, 2012

or +1 on this one :)

prikha commented Jul 13, 2012

Please post any temporary solution for this unless there no way out...

Contributor

juniorz commented Jul 18, 2012

That is what I made: juniorz/inherited_resources@9b51bc3

But, it looks like this gem is "deprecated" and will no longer be updated...

+1 this fix is very needed.

Works on mountable engine (rails 4.0.0)

👍

@rafaelfranca rafaelfranca removed the Bug label Oct 10, 2014

Collaborator

rafaelfranca commented Oct 10, 2014

This need a rebase.

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