Comments (3)
Hmm, this is a scenario I hadn't considered before. There are a number of factors that would make it a tricky fix. The URL rewriting doesn't talk to the routing portion at all, and I'm not sure of a "smart" way to hook that up. Also, as the routing portion of the plugin will be deprecated when Rails 3 comes along, I'm not sure if I'll take the time to dig in or not. A fork+pull would be welcome, though!
from subdomain-fu.
I think the solution is simpler than you make it out to be.
You are correct in your understanding that the url rewriting doesn't talk to the routing portions directly. However, the creation of a named route defines four helpers, one produces the hash that when given to url_for produces the correct route. Another bundles a call to url_for with that hash.
All that really needs to be done is add the subdomain argument to that url_for_hash the helpers produces for named routes created with the :subdomain condition.
I won't really have time to play around with this until the weekend. So hopefully I'll find some time before Monday to fork, tweak, test, and issue a pull request.
I have the feeling that we're looking at a couple line tweak to ActionController::Routing::RouteBuilder around the time divide_route_options is called to copy the :subdomain hash in the :conditions to the default options.
Essentially doing:
options = options.merge({:subdomain => options[:conditions][:subdomain]}) if options[:conditions][:subdomain]
in or before divide_route_options. Probably part of a new alias_method_chain.
I'll have to look a little closer at the subdomain-fu code to ensure the unless subdomain clauses are uneffected. But I don't expect it to take too long.
In hindsight, it seems I've done the hard part while writing this response.
from subdomain-fu.
EmFi: You're right, I just wasn't thinking of it in those terms. If I remember back from when I was implementing, map.resources actually ignores the :conditions hash since the only default condition is :method which is overridden. I think I may have tried to go down that path at some point but stopped short of a full implementation. Anyways, I'd be happy to have a patch!
from subdomain-fu.
Related Issues (20)
- Crash when requesting URL with tld_size different than expected HOT 2
- Routing a controller only to a subdomain
- current_domain returns wrong domain
- Rails3 - no such file to load -- action_controller/url_rewriter HOT 7
- miss routing ajax request
- rspec redirect_to matcher fails if route only exists for a subdomain HOT 3
- default to :subdomain => false for all routes HOT 2
- current_domain includes port
- plugin does honor the :only_path notion of routing when doing so goes against the intent of the command
- Exceptions thrown when someone requests without Host: HTTP header HOT 2
- Failure when generating links in background jobs
- Server won't load; rails/init HOT 1
- current_subdomain in test alway is "test" HOT 2
- Gem won't load in with Bundler 1.1.2, Ruby 1.9.3 HOT 1
- uninitialized constant ActionDispatch::Routing::RouteSet::Mapper HOT 2
- url_for unexpected behaviour HOT 1
- :subdomain not working HOT 3
- Release 1.0.0 HOT 3
- session store issue
- Incompatible with Rails 4.2 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from subdomain-fu.