francesc / rails-translate-routes

MIT License
147 stars 50 forks source link

'host' constraint not working #27

Closed stephanvane closed 12 years ago

stephanvane commented 12 years ago

Hello, I tried using constraints host: 'example.com' in my routes.rb. I think this problem is closely related to #12. Adding conditions[:host] = route.constraints[:host] if route.constraints would work.

I guess that since there could be more constraints a more general solution is in it's place. Replacing the #12 fix with:

if route.constraints
  route.constraints.each do |k,v|
    conditions[k] = v unless k == :request_method
  end
end

works for me. (request_method is left out since it resulted in an error).

I'm not sure if my method introduces new problems. If it does, then a simple conditions[:host] = route.constraints[:host] if route.constraints instead would to the trick.

francesc commented 12 years ago

It looks good to me, did you try it out? I'll make the changes and run a few test asap. Thanks.

stephanvane commented 12 years ago

I tested it on my own project and I didn't see any problems with it. I guess it'll work just fine everywhere. Some double checking couldn't hurt though :) I'm far from an expert on rails routing

francesc commented 12 years ago

I'll try to release it today or next tuesday. Thanks!

stephanvane commented 12 years ago

Thanks you I'll use my branch of the gem in the meantime so take your time :) Great project btw, thanks for the work!