Comments (16)
This might be related to my issue #26.
There is some information out there for a few fixes:
http://www.ruby-forum.com/topic/3448797
However, it didn't help my particular situation out that much.
from route_translator.
I ended up using rails' default way to translate routes (seeing I was only translating actions anyway):
scope path_names: { new: I18n.t('routes.new'), edit: I18n.t('routes.edit') } do
resources :municipios
end
So, I'm not actually using route_translator anymore.
Might be useful to you too, @astjohn.
from route_translator.
+1
Gem seems to work in production, but in test any _path or _url calls without explicit language code cause NoMethodError: undefined method 'foo_path' ...
Any known solutions so far?
from route_translator.
@GSI, you could try giving my fork a try on the "fix_rendered_paths" branch.
https://github.com/astjohn/route_translator/tree/fix_rendered_paths
from route_translator.
@astjohn, thanks for the hint. I'd already tried your fork, but the same tests fail with the same error messages like with the original gem.
I suppose it's working for you. Any idea how your setup might differ?
The only "specialities" in my routes are some constraints, scopes and the devise_for declaration.
from route_translator.
@GSI, hm... not sure. Can you please double check that you're using the branch instead of master on my fork? Your Gemfile should look something like like the following:
gem 'route_translator', git: 'https://github.com/astjohn/route_translator.git', branch: 'fix_rendered_paths'
Then of course bundle install and re-start your server.
from route_translator.
@astjohn that's exactly what I have in my Gemfile. I also tried adding the exact ref just to be sure.
I note that you write "re-start your server" - to clarify: production works fine, but with rake test
whenever calls are made to some ..._path or ..._url (e.g. user_url), there's an NME.
from route_translator.
@GSI,
I'm not sure. I use rspec most of the time, but in my controller tests, assertions on redirects using _path seem to be working well. There's nothing special about our setup, and we have some pretty complicated routes. The translated and un-translated routes all seem to be working well. I'm not sure what else it can be. Sorry I'm all out of insights.
from route_translator.
@enriclluelles, any idea on this?
from route_translator.
I published a Rails 4.0.2 project that reproduces the error:
https://github.com/GSI/route_translator_reproduce_issue-27
When you check it out and run "rake test", you should see the same error as shown in the README.
When removing the line "localized do" (and it's corresponding "end") from config/routes.rb, the "rake test" command succeeds.
from route_translator.
There's a bounty for solving this on oDesk now (https://www.odesk.com/jobs/~014df4f3bce62bb002).
from route_translator.
@GSI,
With the branch I stated above, I have no issues. Here is an snipped from one of our controller tests:
require 'spec_helper'
describe Partner::AppointmentsController do
let(:country) {mock_model(Country).as_null_object}
before do
setup_partner_controller_environment
end
describe "GET index" do
before do
@employee.stub_chain(:locations, :only) {[]}
end
describe "when the company doesn't have any locations yet" do
before do
@company.stub_chain(:locations, :empty?) {true}
end
it "redirects to the location_needed page" do
get :index
response.should redirect_to location_needed_partner_appointments_path
end
end
# etc..
end
That works fine and I can't think of how unit test might be different than rspec in this scenario.
Sorry I can't be of much more help, but it works perfectly fine for me in all environments, including test. (In your example app, you don't have the branch specified for my repo/fix.)
from route_translator.
Thank you for the update @astjohn. I've checked out your branch in the test project (https://github.com/GSI/route_translator_reproduce_issue-27). The problem persists.
Maybe it's Devise-related ... does your project use Devise?
from route_translator.
@GSI, yes. We use Devise so unfortunately, I don't think that's it. However, I would go ahead and add a test model, controller, and routes for something separate to be sure. If you have time, try adding and setting up rspec as well to see if there are any differences there (also a long shot).
from route_translator.
Thanks to @mohamagdy for solving this issue within the PR #45
from route_translator.
PR #45 have been merged into master.
All tests are green but it will help if you can test this new route_translator in your apps before we release it.
from route_translator.
Related Issues (20)
- disable_fallback not working when I18n.fallbacks is configured HOT 7
- Routes not found error after upgrading to Rails 6.0 from Rails 5.1 HOT 4
- Transfer ownership HOT 1
- Two routes for same locale HOT 1
- Unable to translate routes with custom param HOT 7
- Advice Request: route_translator & Accept-Language request header HOT 4
- Missing translated routes in development after routes_reloader.reload! HOT 6
- Require MFA to publish gems HOT 1
- Bump version rubygems for Rails 7 support HOT 1
- Feature request: custom translation for nested resources HOT 5
- How to translate with dynamic root url HOT 1
- RSpec: cannot call non-localized routes name HOT 5
- Optional route params not included in translated URL HOT 2
- Idea pitch: Generate only unique routes and use I18n.fallbacks to generate as little routes as needed HOT 1
- Question: "/" path locale always English HOT 7
- Issue with partial implementation of route_translator HOT 3
- locale path segment not added to translated route (multiple languages on the same host with host locale translation enabled) HOT 3
- undefined method `eager_load!' for RouteTranslator:Module (NoMethodError) HOT 8
- Bug: en named route always generated ignoring config.available_locales HOT 2
- Translating scopes HOT 1
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 route_translator.