Skip to content

fix routing issue #92

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

Closed
wants to merge 12 commits into from
Closed

fix routing issue #92

wants to merge 12 commits into from

Conversation

ipmsteven
Copy link
Contributor

No description provided.

@dtognazzini
Copy link
Contributor

Please update the integration test apps with a Rails engine and write a test verifying these changes work.

@ipmsteven ipmsteven force-pushed the fixRouter2 branch 5 times, most recently from cfa630d to c49737a Compare October 11, 2014 23:59
@ipmsteven
Copy link
Contributor Author

@dtognazzini which rails version we should support? all rails 3.x + rails 4? maybe drop support for rails versions lower then 3.1 vlado/rails_db_info#8

@ipmsteven ipmsteven force-pushed the fixRouter2 branch 2 times, most recently from e930f30 to b5a357a Compare October 13, 2014 06:10
@dtognazzini
Copy link
Contributor

This is great!

To answer your question about support: I think we should support Rails 2.3 to Rails <most-recent> for now. I'd like to move the Rails stuff out of this gem entirely (see #83). Once we've done that, we can explicitly list the versions we support in the new gem's gemspec.

@ipmsteven
Copy link
Contributor Author

@dtognazzini I agree that we should support Rails 2.3 to Rails for now.

but "rails support question" I mean is about rails engine routing support, rails engine is introduced since rails 3.0, we can not provide the engine routing support in application_router.rb for rails 2.3.

However, the dummy forum engine use isolate_namespace method which is introduced since rails 3.1(isolate_namespace is used in our engine codebase pretty common) https://github.com/appfolio/ae_page_objects/blob/fixRouter2/test/test_apps/shared/engines/forum/lib/forum/engine.rb#L3 .

So the question is: do we need support rails 3.0? if "yes", we may figure out an alternative way to do isolate_namespace in the dummy forum engine?

@dtognazzini
Copy link
Contributor

Since this pull is a bug fix, we should aim to support whatever we supported prior to this fix. That is, this fix shouldn't remove support for anything. That said, if the previous implementation did not support Rails 3.0 engines, then this fix doesn't need to add support. I still haven't spent any time looking at this, but generally, my comments hold for bug fixes.

routes.send("#{named_route}_path", *args)
rescue NoMethodError
nil
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert this change. NoMethodError could be raised from any number of places; handling it generically like this means you could end up handling a case you didn't mean to. The previous implementation using respond_to? was specific to what you actually need to check.

@dtognazzini
Copy link
Contributor

Please review:
https://codeclimate.com/github/appfolio/ae_page_objects/compare/fixRouter2

Generally, CodeClimate ratings should improve.

@dtognazzini
Copy link
Contributor

I think it's time to break up application_router.rb into more files. It's incredibly difficult to read.

@@ -77,18 +118,80 @@ def routes
@routes ||= begin
routes_class = Class.new do
include ::Rails.application.routes.url_helpers

def method_missing(name, *args, &block)
engine, named_route = name.to_s.split("__")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why you're splitting on "__". Can you add a comment describing why? Or, better, you could extract this into a "parser" class and reuse it throughout this file.

@ipmsteven ipmsteven closed this Dec 3, 2014
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.

2 participants