Skip to content
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

Rails 4.0 compatibility #43

Open
lassebunk opened this issue Mar 1, 2013 · 35 comments
Open

Rails 4.0 compatibility #43

lassebunk opened this issue Mar 1, 2013 · 35 comments

Comments

@lassebunk
Copy link

Great plugin. But it doesn't work in the newly released Rails 4.0.0.beta1:

LoadError: cannot load such file -- journey
~/.rvm/gems/ruby-2.0.0-p0/gems/i18n_routing-0.6.2/lib/i18n_routing_rails32.rb:2:in `require'
~/.rvm/gems/ruby-2.0.0-p0/gems/i18n_routing-0.6.2/lib/i18n_routing_rails32.rb:2:in `<top (required)>'
~/.rvm/gems/ruby-2.0.0-p0/gems/i18n_routing-0.6.2/lib/i18n_routing.rb:7:in `require'
~/.rvm/gems/ruby-2.0.0-p0/gems/i18n_routing-0.6.2/lib/i18n_routing.rb:7:in `<top (required)>'
~/.rvm/gems/ruby-2.0.0-p0/gems/bundler-1.3.0/lib/bundler/runtime.rb:72:in `require'

Thanks.

@xpepermint
Copy link

+1, rails 4.0.0.rc1

@ncri
Copy link

ncri commented Jun 7, 2013

Check out the rails4 branch in my fork here: https://github.com/ncri/i18n_routing/tree/rails4

As a starting point. No more errors, but not sure if it works properly yet.

@haggen
Copy link

haggen commented Jun 24, 2013

Hey @ncri, it fixed the previous error (cannot load file -- journey) but another error popped up when starting the server:

/Users/Arthur/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/actionpack-4.0.0.rc2/lib/action_dispatch/journey/gtg/builder.rb:7:in `<class:Builder>': uninitialized constant ActionDispatch::Journey::GTG::Builder::Nodes (NameError)
  from /Users/Arthur/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/actionpack-4.0.0.rc2/lib/action_dispatch/journey/gtg/builder.rb:6:in `<module:GTG>'
  from /Users/Arthur/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/actionpack-4.0.0.rc2/lib/action_dispatch/journey/gtg/builder.rb:5:in `<module:Journey>'
  from /Users/Arthur/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/actionpack-4.0.0.rc2/lib/action_dispatch/journey/gtg/builder.rb:4:in `<module:ActionDispatch>'
  from /Users/Arthur/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/actionpack-4.0.0.rc2/lib/action_dispatch/journey/gtg/builder.rb:3:in `<top (required)>'
  from /Users/Arthur/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/actionpack-4.0.0.rc2/lib/action_dispatch/journey.rb:2:in `<top (required)>'
  from /Users/Arthur/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/actionpack-4.0.0.rc2/lib/action_dispatch/journey/router/utils.rb:4:in `<module:ActionDispatch>'
  from /Users/Arthur/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/actionpack-4.0.0.rc2/lib/action_dispatch/journey/router/utils.rb:3:in `<top (required)>'
  from /Users/Arthur/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/actionpack-4.0.0.rc2/lib/action_dispatch/journey/router.rb:1:in `<top (required)>'
  from /Users/Arthur/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/bundler/gems/i18n_routing-e905d1968a19/lib/i18n_routing_rails4.rb:2:in `<top (required)>'
  from /Users/Arthur/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/bundler/gems/i18n_routing-e905d1968a19/lib/i18n_routing.rb:7:in `<top (required)>'
  from /Users/Arthur/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
  from /Users/Arthur/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
  from /Users/Arthur/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
  from /Users/Arthur/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
  from /Users/Arthur/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
  from /Users/Arthur/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
  from /Users/Arthur/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
  from /Users/Arthur/Job/newmarykay/config/application.rb:13:in `<top (required)>'
  from /Users/Arthur/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/railties-4.0.0.rc2/lib/rails/commands.rb:78:in `require'
  from /Users/Arthur/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/railties-4.0.0.rc2/lib/rails/commands.rb:78:in `block in <top (required)>'
  from /Users/Arthur/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/railties-4.0.0.rc2/lib/rails/commands.rb:75:in `tap'
  from /Users/Arthur/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/railties-4.0.0.rc2/lib/rails/commands.rb:75:in `<top (required)>'
  from script/rails:6:in `require'
  from script/rails:6:in `<main>'

@ncri
Copy link

ncri commented Jun 24, 2013

Just use the Rails 4 branch of my fork, it works (for me ;-)

@lassebunk
Copy link
Author

Thanks @ncri 👍 – looking forward to try that out.

@haggen
Copy link

haggen commented Jul 2, 2013

Actually it didn't work for me. But since I had to open up Journey's source and add an extra include line, I suspect the issue is not within your repo. :P

@lassebunk
Copy link
Author

Could someone propose a solution for master?

tirsdag den 2. juli 2013 skrev Arthur Corenzan :

Actually it didn't work for me. But since I had to open up Journey's
source and add an extra include line, I suspect the issue is not within
your repo. :P


Reply to this email directly or view it on GitHubhttps://github.com//issues/43#issuecomment-20363252
.

@ncri
Copy link

ncri commented Jul 4, 2013

I can make a pull request for master soon. until then, you can simply use my rails4 fork. @haggen: did you use the rails4 branch in my repo, or master? do you have a stacktrace for the error?

@lassebunk
Copy link
Author

Thanks very much – that would be great.

@ncri
Copy link

ncri commented Jul 6, 2013

Oops, @haggen, the stack trace was there already, my mistake. Did you only had to fix that one issue?

@ncri
Copy link

ncri commented Jul 6, 2013

#44

@willywg
Copy link

willywg commented Aug 1, 2013

@haggen I have the same problem

@ncri
Copy link

ncri commented Aug 2, 2013

Can you test if adding require 'action_dispatch/journey/nodes/node' on the very top of i18n_routing_rails4.rb fixes that issue?

@meinac
Copy link

meinac commented Aug 2, 2013

I have a problem with i18n localized routes.
here is a part of my yml file

tr: 
  named_routes_path: 
    start_a_project/: yeni-proje-baslat

and here is the route

localized(I18n.available_locales, :verbose => true) do
    match "start_a_project/" => "start_a_project#index", :as => 'start_a_project', :via => :get
end

is there any solution for this situation? I'm using ncri's i18n_routing gem.
Rails 4.0
ruby 1.9.3
i18_routing gem => 'https://github.com/ncri/i18n_routing.git' :branch => 'rails4'

[I18n] > localize route     :                          start_a_project (tr) => /start_a_project(.:format)
/home/vagrant/.rvm/gems/ruby-1.9.3-p194@rails_4_idemamacom/bundler/gems/rails-58cd859caa49/actionpack/lib/action_dispatch/journey/route.rb:46:in `requirements': undefined method `merge' for nil:NilClass (NoMethodError)
    from /home/vagrant/.rvm/gems/ruby-1.9.3-p194@rails_4_idemamacom/bundler/gems/rails-58cd859caa49/actionpack/lib/action_dispatch/routing/route_set.rb:158:in `optimize_helper?'
    from /home/vagrant/.rvm/gems/ruby-1.9.3-p194@rails_4_idemamacom/bundler/gems/rails-58cd859caa49/actionpack/lib/action_dispatch/routing/route_set.rb:150:in `create'
    from /home/vagrant/.rvm/gems/ruby-1.9.3-p194@rails_4_idemamacom/bundler/gems/rails-58cd859caa49/actionpack/lib/action_dispatch/routing/route_set.rb:269:in `define_url_helper'
    from /home/vagrant/.rvm/gems/ruby-1.9.3-p194@rails_4_idemamacom/bundler/gems/i18n_routing-e905d1968a19/lib/i18n_routing_rails4.rb:135:in `define_url_helper'
    from /home/vagrant/.rvm/gems/ruby-1.9.3-p194@rails_4_idemamacom/bundler/gems/rails-58cd859caa49/actionpack/lib/action_dispatch/routing/route_set.rb:282:in `define_named_route_methods'
    from /home/vagrant/.rvm/gems/ruby-1.9.3-p194@rails_4_idemamacom/bundler/gems/rails-58cd859caa49/actionpack/lib/action_dispatch/routing/route_set.rb:124:in `add'
    from /home/vagrant/.rvm/gems/ruby-1.9.3-p194@rails_4_idemamacom/bundler/gems/rails-58cd859caa49/actionpack/lib/action_dispatch/routing/route_set.rb:445:in `add_route'
    from /home/vagrant/.rvm/gems/ruby-1.9.3-p194@rails_4_idemamacom/bundler/gems/i18n_routing-e905d1968a19/lib/i18n_routing_rails4.rb:216:in `block in match'
    from /home/vagrant/.rvm/gems/ruby-1.9.3-p194@rails_4_idemamacom/bundler/gems/i18n_routing-e905d1968a19/lib/i18n_routing_rails4.rb:212:in `each'
    from /home/vagrant/.rvm/gems/ruby-1.9.3-p194@rails_4_idemamacom/bundler/gems/i18n_routing-e905d1968a19/lib/i18n_routing_rails4.rb:212:in `match'
    from /vagrant/config/routes.rb:37:in `block (2 levels) in <top (required)>'
    from /home/vagrant/.rvm/gems/ruby-1.9.3-p194@rails_4_idemamacom/bundler/gems/i18n_routing-e905d1968a19/lib/i18n_routing_rails4.rb:162:in `localized'
    from /vagrant/config/routes.rb:36:in `block in <top (required)>'
    from /home/vagrant/.rvm/gems/ruby-1.9.3-p194@rails_4_idemamacom/bundler/gems/rails-58cd859caa49/actionpack/lib/action_dispatch/routing/route_set.rb:341:in `instance_exec'
    from /home/vagrant/.rvm/gems/ruby-1.9.3-p194@rails_4_idemamacom/bundler/gems/rails-58cd859caa49/actionpack/lib/action_dispatch/routing/route_set.rb:341:in `eval_block'
    from /home/vagrant/.rvm/gems/ruby-1.9.3-p194@rails_4_idemamacom/bundler/gems/rails-58cd859caa49/actionpack/lib/action_dispatch/routing/route_set.rb:319:in `draw'
    from /vagrant/config/routes.rb:1:in `<top (required)>'
    from /home/vagrant/.rvm/gems/ruby-1.9.3-p194@rails_4_idemamacom/bundler/gems/rails-58cd859caa49/activesupport/lib/active_support/dependencies.rb:222:in `load'
    from /home/vagrant/.rvm/gems/ruby-1.9.3-p194@rails_4_idemamacom/bundler/gems/rails-58cd859caa49/activesupport/lib/active_support/dependencies.rb:222:in `block in load'
    from /home/vagrant/.rvm/gems/ruby-1.9.3-p194@rails_4_idemamacom/bundler/gems/rails-58cd859caa49/activesupport/lib/active_support/dependencies.rb:213:in `load_dependency'
    from /home/vagrant/.rvm/gems/ruby-1.9.3-p194@rails_4_idemamacom/bundler/gems/rails-58cd859caa49/activesupport/lib/active_support/dependencies.rb:222:in `load'
    from /home/vagrant/.rvm/gems/ruby-1.9.3-p194@rails_4_idemamacom/bundler/gems/rails-58cd859caa49/railties/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
    from /home/vagrant/.rvm/gems/ruby-1.9.3-p194@rails_4_idemamacom/bundler/gems/rails-58cd859caa49/railties/lib/rails/application/routes_reloader.rb:40:in `each'
    from /home/vagrant/.rvm/gems/ruby-1.9.3-p194@rails_4_idemamacom/bundler/gems/rails-58cd859caa49/railties/lib/rails/application/routes_reloader.rb:40:in `load_paths'
    from /home/vagrant/.rvm/gems/ruby-1.9.3-p194@rails_4_idemamacom/bundler/gems/rails-58cd859caa49/railties/lib/rails/application/routes_reloader.rb:16:in `reload!'
    from /home/vagrant/.rvm/gems/ruby-1.9.3-p194@rails_4_idemamacom/bundler/gems/rails-58cd859caa49/railties/lib/rails/application/routes_reloader.rb:26:in `block in updater'
    from /home/vagrant/.rvm/gems/ruby-1.9.3-p194@rails_4_idemamacom/bundler/gems/rails-58cd859caa49/activesupport/lib/active_support/file_update_checker.rb:75:in `call'
    from /home/vagrant/.rvm/gems/ruby-1.9.3-p194@rails_4_idemamacom/bundler/gems/rails-58cd859caa49/activesupport/lib/active_support/file_update_checker.rb:75:in `execute'
    from /home/vagrant/.rvm/gems/ruby-1.9.3-p194@rails_4_idemamacom/bundler/gems/rails-58cd859caa49/railties/lib/rails/application/routes_reloader.rb:27:in `updater'
    from /home/vagrant/.rvm/gems/ruby-1.9.3-p194@rails_4_idemamacom/bundler/gems/rails-58cd859caa49/railties/lib/rails/application/routes_reloader.rb:6:in `execute_if_updated'
    from /home/vagrant/.rvm/gems/ruby-1.9.3-p194@rails_4_idemamacom/bundler/gems/rails-58cd859caa49/railties/lib/rails/application/finisher.rb:69:in `block in <module:Finisher>'
    from /home/vagrant/.rvm/gems/ruby-1.9.3-p194@rails_4_idemamacom/bundler/gems/rails-58cd859caa49/railties/lib/rails/initializable.rb:30:in `instance_exec'
    from /home/vagrant/.rvm/gems/ruby-1.9.3-p194@rails_4_idemamacom/bundler/gems/rails-58cd859caa49/railties/lib/rails/initializable.rb:30:in `run'
    from /home/vagrant/.rvm/gems/ruby-1.9.3-p194@rails_4_idemamacom/bundler/gems/rails-58cd859caa49/railties/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /home/vagrant/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/tsort.rb:150:in `block in tsort_each'
    from /home/vagrant/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'
    from /home/vagrant/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/tsort.rb:219:in `each_strongly_connected_component_from'
    from /home/vagrant/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/tsort.rb:182:in `block in each_strongly_connected_component'
    from /home/vagrant/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/tsort.rb:180:in `each'
    from /home/vagrant/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/tsort.rb:180:in `each_strongly_connected_component'
    from /home/vagrant/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/tsort.rb:148:in `tsort_each'
    from /home/vagrant/.rvm/gems/ruby-1.9.3-p194@rails_4_idemamacom/bundler/gems/rails-58cd859caa49/railties/lib/rails/initializable.rb:54:in `run_initializers'
    from /home/vagrant/.rvm/gems/ruby-1.9.3-p194@rails_4_idemamacom/bundler/gems/rails-58cd859caa49/railties/lib/rails/application.rb:215:in `initialize!'
    from /home/vagrant/.rvm/gems/ruby-1.9.3-p194@rails_4_idemamacom/bundler/gems/rails-58cd859caa49/railties/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /vagrant/config/environment.rb:4:in `<top (required)>'
    from /home/vagrant/.rvm/gems/ruby-1.9.3-p194@rails_4_idemamacom/bundler/gems/rails-58cd859caa49/activesupport/lib/active_support/dependencies.rb:228:in `require'
    from /home/vagrant/.rvm/gems/ruby-1.9.3-p194@rails_4_idemamacom/bundler/gems/rails-58cd859caa49/activesupport/lib/active_support/dependencies.rb:228:in `block in require'
    from /home/vagrant/.rvm/gems/ruby-1.9.3-p194@rails_4_idemamacom/bundler/gems/rails-58cd859caa49/activesupport/lib/active_support/dependencies.rb:213:in `load_dependency'
    from /home/vagrant/.rvm/gems/ruby-1.9.3-p194@rails_4_idemamacom/bundler/gems/rails-58cd859caa49/activesupport/lib/active_support/dependencies.rb:228:in `require'
    from /home/vagrant/.rvm/gems/ruby-1.9.3-p194@rails_4_idemamacom/bundler/gems/rails-58cd859caa49/railties/lib/rails/application.rb:189:in `require_environment!'
    from /home/vagrant/.rvm/gems/ruby-1.9.3-p194@rails_4_idemamacom/bundler/gems/rails-58cd859caa49/railties/lib/rails/commands.rb:61:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

@willywg
Copy link

willywg commented Aug 2, 2013

require 'action_dispatch/journey/nodes/node' don't fix the problem :S

@ncri
Copy link

ncri commented Aug 2, 2013

@mehmetemininac: I'm only using i18n routing for resource routes, not for named routes, as i had many issues with those. So I didn't test my branch with named routes.

@willywg: so you still get exactly the same error? can you make a minimla testapp available on github that reproduces the issue?

@willywg
Copy link

willywg commented Aug 2, 2013

@ncri I put require 'action_dispatch/journey' on the top of i18n_routing_rails4.rb and fix my problem.

@tilsammans
Copy link

Everyone: for me the gem 'route_translator' works out of the box with the same configuration of i18n_routing.

It seems better supported too.

@lassebunk
Copy link
Author

@tilsammans Does the route_translator gem also work without having the locale in the URL?

@tilsammans
Copy link

Yes.

I had to set the available locales to just the one I want to support, because otherwise there were many routes generated with unused locales.

Example, in config/initializers/i18n.rb:

# Limit available locales to the ones actually in use.
# Mostly limits the number of routes generated.
I18n.available_locales = [:nl]

Also the translations are under a different namespace, they are now all under "routes".

@lassebunk
Copy link
Author

Okay, what happens if you have more than one, e.g. four?

@tilsammans
Copy link

I don't know, try it out yourself. 🐱

@lassebunk
Copy link
Author

@willywg's require 'action_dispatch/journey' is also needed in my app to get it to work.
Could you add this to your pull request? Thanks in advance.

@lassebunk
Copy link
Author

(cc @ncri)

@ncri
Copy link

ncri commented Aug 31, 2013

Added

@lassebunk
Copy link
Author

Thanks 😊

@nicolasgarnil
Copy link

Does it works on Rails 4? If so, the README should be updated.

@lassebunk
Copy link
Author

@negarnil Check out #43 (comment) for details. It's not in master yet. It works ok, but not optimal – for me anyway.

@ncri
Copy link

ncri commented Sep 16, 2013

Yes, i believe my fork still needs some work, but for us it does all we need so far...

A bit off topic: To be honest the codebase of this gem is well, slightly messy. :) Huge methods that are hard to debug and maintain... No offence to the creator, it is an incredibly useful gem and there are not many alternatives out there, so thanks for making it! In my opinion we need route translation in the rails core though...

@lassebunk
Copy link
Author

@ncri, I agree. I think your fork is fine – the problem is the base, IMO.

I'd really like to make a replacement for it, but I just don't know anything about the router internals. But there must be a better solution – none of the current ones work great.

Yeah, I don't understand why it's not in Rails core – @dhh, do you have a comment?

@erikostling
Copy link

Hello!

I'm getting this error:

/Users/erikostling/.rvm/gems/ruby-1.9.3-p448/gems/actionpack-4.0.0/lib/action_dispatch/journey/route.rb:38:in `requirements': undefined method `merge' for nil:NilClass (NoMethodError)

on this route:

localized do  
    get "forbehall", to: "pages#disclaimer", as: "disclaimer"
end

Anyone else having the same problem? Using @ncri's fork.

@ncri
Copy link

ncri commented Sep 20, 2013

mehmetemininac has the same error. I haven't looked into making the rails 4 fork work with named routes as I even had troubles getting those working correctly with the rails 3 branch. So, only resource routes work for now.

@erikostling
Copy link

Ah, I understand! Thanks for the quick reply.

@prusswan
Copy link

@ncri I have resolved the path.requirements.merge error, how can I tag on to your pull request?

@ncri
Copy link

ncri commented Dec 11, 2013

You could either create a new pull request and copy my code over or, maybe easier, just fork my fork and create a pull request there: https://github.com/ncri/i18n_routing/tree/master

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

No branches or pull requests

10 participants