Giter VIP home page Giter VIP logo

Comments (16)

astjohn avatar astjohn commented on August 12, 2024

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.

rachel-carvalho avatar rachel-carvalho commented on August 12, 2024

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.

GSI avatar GSI commented on August 12, 2024

+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.

astjohn avatar astjohn commented on August 12, 2024

@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.

GSI avatar GSI commented on August 12, 2024

@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.

astjohn avatar astjohn commented on August 12, 2024

@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.

GSI avatar GSI commented on August 12, 2024

@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.

astjohn avatar astjohn commented on August 12, 2024

@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.

GSI avatar GSI commented on August 12, 2024

@enriclluelles, any idea on this?

from route_translator.

GSI avatar GSI commented on August 12, 2024

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.

GSI avatar GSI commented on August 12, 2024

There's a bounty for solving this on oDesk now (https://www.odesk.com/jobs/~014df4f3bce62bb002).

from route_translator.

astjohn avatar astjohn commented on August 12, 2024

@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.

GSI avatar GSI commented on August 12, 2024

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.

astjohn avatar astjohn commented on August 12, 2024

@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.

GSI avatar GSI commented on August 12, 2024

Thanks to @mohamagdy for solving this issue within the PR #45

from route_translator.

gi-lunaweb avatar gi-lunaweb commented on August 12, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.