heroku: ActionController::RoutingError (No route matches [GET] "/newrelic") - ruby

ERROR
ActionController::RoutingError (No route matches [GET] "/newrelic")
# and I am getting error page for both staging and production heroku servers
Documentation
https://devcenter.heroku.com/articles/newrelic
GEM
https://github.com/newrelic/rpm
# ruby 2.1.0p0
# rails 4.0.1
Both environment variables NEW_RELIC_LICENSE_KEY and NEW_RELIC_APP_NAME are set to heroku config variable
Gemfile
gem "newrelic_rpm", "~> 3.5.7.59"
config/newrelic.yml
common: &default_settings
license_key: <%= ENV['NEW_RELIC_LICENSE_KEY'] %>
app_name: <%= ENV["NEW_RELIC_APP_NAME"] %>
monitor_mode: true
developer_mode: false
log_level: info
browser_monitoring:
auto_instrument: true
audit_log:
enabled: false
capture_params: false
transaction_tracer:
enabled: true
transaction_threshold: apdex_f
record_sql: obfuscated
stack_trace_threshold: 0.500
error_collector:
enabled: true
capture_source: true
ignore_errors: "ActionController::RoutingError,Sinatra::NotFound"
development:
<<: *default_settings
monitor_mode: true
developer_mode: true
test:
<<: *default_settings
monitor_mode: false
production:
<<: *default_settings
monitor_mode: true
staging:
<<: *default_settings
monitor_mode: true
app_name: <%= ENV["NEW_RELIC_APP_NAME"] %> (Staging)
[NOTE: I have two application hosted to heroku:]
(staging).herokuapp.com
(production).herokuapp.com
And I want to configure new-relic for both environments/servers.
Also, Note that this configuration is working fine in development(localhost) environmet.
EDITED
config/routes.rb
Demo::Application.routes.draw do
root :to => "home#index"
devise_for :users,:controllers => {:sessions => "sessions",:omniauth_callbacks => "omniauth_callbacks" }
post '/tinymce_assets' => 'tinymce_assets#create'
resources :home
namespace :admin do
resources :dashboards
resources :users do
member do
get :reset
put :reset_pw
put :delete_record
put :restore_user
end
end
end
resources :drives do
member do
put :destroy_drive
post :add_consolidation
put :delete_consolidation
post :add_driveorganizer
put :delete_drive_organizer
put :restore_drirve
end
collection do
get :recalculate_consolidation
end
resources :drive_details do
resources :images
end
end
resources :products do
member do
post :add_category
put :destroy_pc
put :delete_product
put :restore_products
end
end
resources :stores do
member do
put :delete_store
end
end
resources :store_products do
member do
put :delete_storeproduct
post :add_package_items
put :delete_package_item
put :restore_store_product
get :get_product_price
end
collection do
get :autocomplete_others
end
end
resources :orders do
member do
put :delete_order
put :restore_order
get :charge_stripe
end
resources :order_items do
collection do
post :display_price
end
member do
put :delete_record
end
end
end
resources :categories do
member do
put :delete_category
put :restore_category
end
collection do
get :move
end
end
namespace :user do
resources :campaigns do
member do
get :single_campaign
end
resources :stores
resources :carts do
collection do
post :carts_update
get :checkout_final
get :payment
post :payment
get :update_payment
get :update_payment_and_redirect
get :confirmation
post :confirmation
get :finish
post :confirmation_update
put :empty_cart
post :shelter_survey
end
member do
put :destroy_oi
put :checkout
end
end
end
end
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
# root 'welcome#index'
# Example of regular route:
# get 'products/:id' => 'catalog#view'
# Example of named route that can be invoked with purchase_url(id: product.id)
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
# Example resource route (maps HTTP verbs to controller actions automatically):
# resources :products
# Example resource route with options:
# resources :products do
# member do
# get 'short'
# post 'toggle'
# end
#
# collection do
# get 'sold'
# end
# end
# Example resource route with sub-resources:
# resources :products do
# resources :comments, :sales
# resource :seller
# end
# Example resource route with more complex sub-resources:
# resources :products do
# resources :comments
# resources :sales do
# get 'recent', on: :collection
# end
# end
# Example resource route with concerns:
# concern :toggleable do
# post 'toggle'
# end
# resources :posts, concerns: :toggleable
# resources :photos, concerns: :toggleable
# Example resource route within a namespace:
# namespace :admin do
# # Directs /admin/products/* to Admin::ProductsController
# # (app/controllers/admin/products_controller.rb)
# resources :products
# end
end
Thanks

Based on the error you're getting, it looks like you're trying to access the route to the New Relic Ruby agent's developer mode in your staging and production environments. Developer mode installs a middleware in your app that responds to any URL prepended with /newrelic. Because you've enabled Developer mode in your development (localhost) environment (the developer_mode key is set to true in your newrelic.yml under development), accessing this route succeeds there, but it fails in staging and production because you don't have developer mode enabled in those environments.
Your current configuration is usually desirable, since Developer mode introduces a large amount of overhead that is generally unacceptable in production. Rather than attempt to access the route in staging or production, use it during development only.
You may also want to consider upgrading the version of the agent you are using, since version 3.5.7 does not fully support Ruby 2.0 or Rails 4. More information on releases can be found at https://docs.newrelic.com/docs/releases/ruby.

Related

Ruby Rails Cucumber Troubleshooting

I am trying to build an app with Cucumber for the first time, using Rails 5.2.6, Rspec, Capybara and Factory bot.
I successfully got through my first feature with scenarios for authentication with devise.
UPDATE
Through a series of troubleshooting steps, detailed below, the problem is that the controller collection #cocktails somehow isn't passing to the view ONLY in the cucumber test.
With the rails server, it passes with no problem.
I checked and #cocktails only appears on the controller and the view. So its not getting overwritten or erased, at least directly.
Its working in the unit RSpec test and also rails server.
How it is not getting passed in the cucumber test? Can anyone see why it wouldn't pass from the controller to the test?
But I hit a snag in my second feature file for CRUD functionality. The very first given step uses FactoryBot to create 2 items, log in the user and go straight to the index for just those two items. But the page shows the view but not the 2 created items as confirmed by using:
puts page.body
in the cucumber file
When I create them on the actual application, it functions correctly, goes straight to the index and displays them.
So I'm trying to figure out how to troubleshoot this. My first thought is to find a way to confirm that FactoryBot created the 2 items. My second thought is to confirm they are actually set to the user. I have tried to use puts to display the two created objects or the user, but I haven't figured out how to call upon them within cucumber.
This is the step file:
Given('I have populated a cocktail list for this User') do
FactoryBot.create(:cocktail,
:user => #registered_user,
:name => "Frank Wallbanger",
:ingredients => "Lots of Booze, a pinch of lime")
FactoryBot.create(:cocktail,
:user => #registered_user,
:name => "Fuzzy Naval Orange",
:ingredients => "Lots of Tequila, a pinch of orange")
end
When('I visit the website and log in') do
expect(page).to have_content("Signed in successfully")
end
Then('I will see the cocktail list') do
puts page.body
expect(page).to have_content("Frank Wallbanger")
expect(page).to have_content("Fuzzy Naval Orange")
end
This is my RSpec unit test file and its green
require "rails_helper"
RSpec.describe CocktailsController do
let(:user) { instance_double(User) }
before { log_in(user) }
describe "GET #index" do
let(:cocktails) { [
instance_double(Cocktail),
instance_double(Cocktail)
] }
before do
allow(user).to receive(:cocktails).and_return(cocktails)
get :index
end
it "looks up all cocktails that belong to the current user" do
expect(assigns(:cocktails)).to eq(cocktails)
end
end
end
This is rails_helper.rb
# This file is copied to spec/ when you run 'rails generate rspec:install'
require 'spec_helper'
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../config/environment', __dir__)
# Prevent database truncation if the environment is production
abort("The Rails environment is running in production mode!") if Rails.env.production?
require 'rspec/rails'
# Add additional requires below this line. Rails is not loaded until this point!
# Requires supporting ruby files with custom matchers and macros, etc, in
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
# run as spec files by default. This means that files in spec/support that end
# in _spec.rb will both be required and run as specs, causing the specs to be
# run twice. It is recommended that you do not name files matching this glob to
# end with _spec.rb. You can configure this pattern with the --pattern
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
#
# The following line is provided for convenience purposes. It has the downside
# of increasing the boot-up time by auto-requiring all files in the support
# directory. Alternatively, in the individual `*_spec.rb` files, manually
# require only the support files necessary.
#
# Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f }
# Checks for pending migrations and applies them before tests are run.
# If you are not using ActiveRecord, you can remove these lines.
begin
ActiveRecord::Migration.maintain_test_schema!
rescue ActiveRecord::PendingMigrationError => e
puts e.to_s.strip
exit 1
end
RSpec.configure do |config|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true
# You can uncomment this line to turn off ActiveRecord support entirely.
# config.use_active_record = false
# RSpec Rails can automatically mix in different behaviours to your tests
# based on their file location, for example enabling you to call `get` and
# `post` in specs under `spec/controllers`.
#
# You can disable this behaviour by removing the line below, and instead
# explicitly tag your specs with their type, e.g.:
#
# RSpec.describe UsersController, type: :controller do
# # ...
# end
#
# The different available types are documented in the features, such as in
# https://relishapp.com/rspec/rspec-rails/docs
config.infer_spec_type_from_file_location!
# Filter lines from Rails gems in backtraces.
config.filter_rails_from_backtrace!
# arbitrary gems may also be filtered via:
# config.filter_gems_from_backtrace("gem name")
end
Shoulda::Matchers.configure do |config|
config.integrate do |with|
with.test_framework :rspec
with.library :active_record
with.library :active_model
with.library :action_controller
with.library :rails
end
end
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.strategy = :transaction
DatabaseCleaner.clean_with(:truncation)
end
config.around(:each) do |example|
DatabaseCleaner.cleaning do
example.run
end
end
end
require "support/controller_helpers"
RSpec.configure do |config|
config.include Warden::Test::Helpers
config.include Devise::Test::ControllerHelpers, :type => :controller
config.include ControllerHelpers, :type => :controller
end
This is the controller I'm testing:
class CocktailsController < ApplicationController
before_action :set_cocktail, only: %i[ show edit update destroy ]
# GET /cocktails or /cocktails.json
def index
#cocktails = current_user.cocktails
end
# GET /cocktails/1 or /cocktails/1.json
def show
end
# GET /cocktails/new
def new
#cocktail = Cocktail.new
render :new
end
# GET /cocktails/1/edit
def edit
end
# POST /cocktails or /cocktails.json
def create
#cocktail = Cocktail.new cocktail_params.merge(user: current_user)
if #cocktail.save
redirect_to cocktails_path
else
render :new
end
end
# PATCH/PUT /cocktails/1 or /cocktails/1.json
def update
respond_to do |format|
if #cocktail.update(cocktail_params)
format.html { redirect_to #cocktail, notice: "Cocktail was successfully updated." }
format.json { render :show, status: :ok, location: #cocktail }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: #cocktail.errors, status: :unprocessable_entity }
end
end
end
# DELETE /cocktails/1 or /cocktails/1.json
def destroy
#cocktail.destroy
respond_to do |format|
format.html { redirect_to cocktails_url, notice: "Cocktail was successfully destroyed." }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_cocktail
#cocktail = Cocktail.find(params[:id])
end
# Only allow a list of trusted parameters through.
def cocktail_params
params.require(:cocktail).permit(:name, :ingredients, :user)
end
end
I'm totally new to this so if there are other files you need to see let me know or if I put a block in a bad area.
At the minimum, I'm just looking for how to display the values. The user login runs with the previous steps file where #registered_user was created and it seems to persist with the second step that confirms "Signed in successfully". So I'm down to the items not created or not assigned to the user as my most likely suspects.
Thanks
Here is the index.html.erb view
<h1>Cocktails</h1>
<table>
<thead>
<tr>
<th>Name</th>
<th>Ingredients</th>
<th>User</th>
<th colspan="3"></th>
</tr>
</thead>
<tbody>
<% #cocktails.each do |cocktail| %>
<tr>
<td><%= cocktail.name %></td>
<td><%= cocktail.ingredients %></td>
<td><%= cocktail.user_id %></td>
<td><%= link_to 'Show', cocktail %></td>
<td><%= link_to 'Edit', edit_cocktail_path(cocktail) %></td>
<td><%= link_to 'Destroy', cocktail, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
</table>
<br>
<%= link_to 'New Cocktail', new_cocktail_path %>
<%= button_to 'Log out', destroy_user_session_path, :method => :delete %>
So, after Lam's suggestion below, I tried this attempt to verify.
I went rails console, and tried to run that first FactoryBot.create from the step file. That produced an error that the user #registered_user doesn't exist. Which makes sense in the console. So I can't verify that. BUT, if I created #registered_user from an existing user, that snippet successfully reacted the Frank Wallbanger cocktail. So it seems the FactoryBot is functional. So perhaps is the #registered_user that is the problem?
So I added "puts #registered_user" to the steps file and it did print an active record to the cucumber output.
When I run the rails server and display that view, I see the cocktails listed out. But its still blank in that area of the cucumber output from the "puts page.body" line in the steps file.
UPDATE
Ok, I think I zeroed down to the cause. But not the fix.
In the controller index
#cocktails = current_user.cocktails
Is working on the rails server, but it is NOT populated in the cucumber test.
I added this code to the view
<% if #cocktails.any? %>
<%= #cocktails.first.name %>
<% else %>
<p> none </p>
<% end %>
So why would it not be passing? I tried changing the controller to:
#cocktails = Cocktail.all
And that also doesn't work.
Ok, I finally got it.
I needed to put add visit root_path on the Then step of the step file. And it finally all cleared up.
Then('I will see the cocktail list') do
visit root_path
expect(page).to have_content("Frank Wallbanger")
expect(page).to have_content("Fuzzy Naval Orange")
end
I need a beer.....
You should avoid using Factory Bot when cuking. A better pattern to use with Rails follows.
Have the create and update actions of your controller call a service rather than call Active Record directly.
Your services take new model objects and save or update them. They return a Result hash which contains the following keys [success, model]
If your service succeeds {success: true, model: model}
If your service fails {success: false, model: model(with errrors),... }
Your services create a place for you to deal with business logic that occurs when you create an event e.g. send emails, audit the event, background long running processes etc. etc.
Now you can create things quickly in your Cuking by
a) Initialising a suitable model object with params
b) Calling the service and passing in the model
Ideally you would do this in helper methods that are called in your step defs.
This replaces FactoryBot and at the same time ensures that all the objects you create are created correctly with the same business logic that your application uses. Its very fast (a bit faster than factory bot and way faster than using the UI). It avoids you having to duplicate business logic by configuring FactoryBot to match your applications business logic. And finally it provides far more flexibility in applying business logic than relying solely on ActiveModel callbacks.
This gives you a pattern for CRUD. When you start with something new you will have
Scenario: Create a foo
Given ...
When I create a new foo
Then I should have a new foo
This will drive the development of the model, controller, controller#new, view#new, form, controller#create, controller#show view#show
Once you have these and have followed the pattern above you can then use foo in your givens e.g
Given there is a foo
When I bar with my foo
...
and you can create the foo with no user interaction and no need for Factories.
e.g
module FooSH
def create_foo(foo: )
Result = CreateFooService.new(foo: foo).call
Result.model
end
def create_default_foo
Result = CreateFooService.new(foo: Foo.new(default_foo_params).call
Result.model
end
def default_foo_params
{
}
end
end
World FooSH
and then your step
Given 'there is a foo' do
#foo = create_default_foo
end
You can apply your own styles and patterns to this and expand on object creation in a number of ways. You can see an example of this in this rather old repo https://github.com/diabolo/cuke_up

Rails 6 ActionMailbox with Mailgun returning 404

I am developing an in-house expenses application on Rails 6 with ActionMailbox to replace Excel spreadsheets. As many of our receipts are now in email form (for example airline tickets), the idea is that users will be able to simply forward a receipt to the application and it will automatically be associated with the expense entry.
I am using ActionMailbox with Mailgun as the email receiver. As suggested by the Gorails Pro tutorial I have exposed my app using localtunnel to the general Internet. I have used Mailgun's facility to send a test email to my application.
My post address is:
https://xxxxxxxx.localtunnel.me/rails/action_mailbox/mailgun/inbound_emails/mime
However, I have run into an issue where the incoming email from Mailgun is not being processed correctly but is being returned with a 404 error. The Rails log shows the message being received as a POST. The last two entries in the log are:
2019-10-15T07:50:07.646Z 10260 TID-gn609ivg8 INFO: Filter chain halted as :ensure_configured rendered or redirected
2019-10-15T07:50:07.646Z 10260 TID-gn609ivg8 INFO: Completed 404 Not Found in 0ms (ActiveRecord: 0.0ms | Allocations: 144)
My configuration is:
config/routes.rb
Rails.application.routes.draw do
devise_for :users
resources :categories
resources :expense_claims do
get 'export_excel', on: :member
post 'barclay_csv_import', on: :collection
end
resources :expense_entries
root 'expense_claims#index'
# Enable the sidekiq console.
require 'sidekiq/web'
mount Sidekiq::Web => '/sidekiq'
end
config/application.rb
module Expenses
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.2
# Settings in config/environments/* take precedence over those specified here.
# Application configuration can go into files in config/initializers
# -- all .rb files in that directory are automatically loaded after loading
# the framework and any gems in your application.
# Set the ActionMailbox ingress here for now.
config.action_mailbox.ingress = :mail_gun
end
end
config/environments/development.rb
Rails.application.configure do
[... lot of stuff removed as not relevant]
# Settings specified here will take precedence over those in config/application.rb.
config.action_mailer.default_url_options = { host: '0.0.0.0', port: 3000 }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = { address: '0.0.0.0', port: 1025 }
# Set the active job queue adapter to Sidekiq/Redis
# config.active_job.queue_adapter = :sidekiq
# Alternatively, when debugging, you can set to in-line (or :async)
config.active_job.queue_adapter = :inline
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
config.action_mailer.perform_caching = false
# Set so we can test Devise self registration
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
# Allow traffic from localtunnel
config.hosts << 'xxxxxx.localtunnel.me'
end
app/mailboxes/application_mailbox.rb
class ApplicationMailbox < ActionMailbox::Base
routing :all => :receipt
end
app/mailboxes/receipt_mailbox.rb
class ReceiptMailbox < ApplicationMailbox
# mail => Mail object
# inbound_email => ActionMailboxEmail record
def process
end
end
Well, turns out it was the most stupid of mistakes. In config/application.rb the final configuration was wrong. I needed to replace :mail_gun with :mailgun:
# Set the ActionMailbox ingress here for now.
config.action_mailbox.ingress = :mailgun
Unfortunately, the Rails error message was not very helpful here.
To give a little more info, ActionMailbox has a number of different routes defined for different email processors. Therefore, the URL to which the email processor posts the incoming email defines the controller to use. On receiving an email, Rails checks that the URL to which the email has been posted matches the ingress class that is set in the config. If not, you get the error I saw.

Update route to support two separate calls

Currently i have route as below
namespace :books
resources :pages, only: [] do
post 'lesson'
end
end
Path: DB/DB_id/user/user_id/books/pages/page_id/lesson
How do i update the route to support following path?
DB/DB_id/user/user_id/books
I am not passing any book_id. just want to list all books
namespace :books
get "/", to: "books#index"
resources :pages, only: [] do
post 'lesson'
end
end
Of course if you eventually do want to access individual books, you'll want to make books a resource so you can easily add routes later.
resources :books, only: [:index] do
resources :pages, only: [] do
post 'lesson'
end
end

Issue with Routes when implementing a nested form

I am building out a CAD App with Rails 4 Ruby 2
I have a Call model and a Update model and I am beginning the process to nest the Update into my call.
I have already completed the views and controller nesting etc but I seem to be hung up on my Routes.rb.
The error I am getting is:
Can't use collection outside resource(s) scope
My Routes.rb file looks like:
resources :calls do
resources :updates, except: [:index], controller: 'calls/updates'
end
collection do
get 'history'
end
member do
patch :update_unit_on_scene
patch :update_unit_clear
patch :update_unit2_os
patch :update_unit2_cl
patch :update_unit3_os
patch :update_unit3_cl
patch :update_unit4_os
patch :update_unit4_cl
end
I am very new with Nested forms / views etc so I am thinking this is where I am going wrong.
My Full Routes File:
Rails.application.routes.draw do
devise_for :users, controllers: { registrations: 'registrations' }
devise_scope :user do
authenticated :user do
root 'calls#index', as: :authenticated_root
end
unauthenticated do
root 'devise/sessions#new', as: :unauthenticated_root
end
end
resources :sites
resources :calls do
resources :updates, except: [:index], controller: 'calls/updates'
end
collection do
get 'history'
end
member do
patch :update_unit_on_scene
patch :update_unit_clear
patch :update_unit2_os
patch :update_unit2_cl
patch :update_unit3_os
patch :update_unit3_cl
patch :update_unit4_os
patch :update_unit4_cl
end
end
Your routes file seems to have a misplaced end keyword. Try writing your routes file like so:
Rails.application.routes.draw do
devise_for :users, controllers: { registrations: 'registrations' }
devise_scope :user do
authenticated :user do
root 'calls#index', as: :authenticated_root
end
unauthenticated do
root 'devise/sessions#new', as: :unauthenticated_root
end
end
resources :sites
resources :calls do
resources :updates, except: [:index], controller: 'calls/updates'
# end keyword was placed here initially, which was closing off
# the resource scope for the routes being defined below,
# causing the error you were seeing
collection do
get 'history'
end
member do
patch :update_unit_on_scene
patch :update_unit_clear
patch :update_unit2_os
patch :update_unit2_cl
patch :update_unit3_os
patch :update_unit3_cl
patch :update_unit4_os
patch :update_unit4_cl
end
# moving end keyword to this position ensures that the calls resource
# properly encloses the collection and member routes
end
end
Hope it helps!

Ruby Rails 3.2 Locale with folder_name path in URL

I have a trio of Ruby/Rails applets running under the following setup:
services.mydomain.com/applet1
services.mydomain.com/applet2
services.mydomain.com/applet3
These are served via Phusion Passenger, and App1 and App2 work exactly as expected.
The problem is with App3 which uses I18n Locales embedded in the URL:
services.mydomain.com/applet3/en/
services.mydomain.com/applet3/fr/
services.mydomain.com/applet3/es/
The problem seems to be that the link_to URLs don't seem to include the "applet3". So instead of:
services.mydomain.com/applet3/en/signin
I get:
services.mydomain.com/en/signin
... which is unrouteable.
My routes.rb looks like:
Rails.application.routes.draw do
scope "(:locale)", locale: /#{I18n.available_locales.join("|")}/ do
resources :users
resources :sessions, only: [:new, :create, :destroy]
match '/signup', to: 'users#new'
match '/signin', to: 'sessions#new'
match '/signout', to: 'sessions#destroy', via: :delete
match '/help', to: 'static_pages#help'
match '/about', to: 'static_pages#about'
root to: "static_pages#home"
end # scope locale
end # Rails.application.routes.draw do
... and in app/controllers/application_controller.rb I have:
before_filter :set_locale_from_params
def url_options
{ only_path: true, locale: I18n.locale }
end
protected
def set_locale_from_params
if params[:locale]
if I18n.available_locales.include?(params[:locale].to_sym)
I18n.locale = params[:locale]
else
flash.now[:notice] = 'Translation not available'
logger.error flash.now[:notice]
end
end
end
... and in config/environments/production.rb I have:
Rails.application.routes.default_url_options[:host] = 'http://services.mydomain.com/applet3/'
EDIT1: add example link_to statement
<%= link_to(t(".#{language}"), root_path(locale: language)) %>
/EDIT1
If I move App3 to a more "normal" arrangement where there is no "folder_name" in the URL path, everything works fine. So it's something simple I'm missing with how to set up the scope or the URL Options.
Thanks in advance for any help & suggestions!
what about use constraints into your route to define your sub module route ?
Rails.application.routes.draw do
constraints(:host) do
scope :path => ":locale" , locale: /#{I18n.available_locales.join("|")}/ do
resources :users
resources :sessions, only: [:new, :create, :destroy]
match '/signup', to: 'users#new'
match '/signin', to: 'sessions#new'
match '/signout', to: 'sessions#destroy', via: :delete
match '/help', to: 'static_pages#help'
match '/about', to: 'static_pages#about'
root to: "static_pages#home"
end # scope locale
end # constraints
end # Rails.application.routes.draw do
You are using root_path and expecting applet3 to be added, on doing rake routes did you check what was the path for root ?
You might have to explicitly set the root path in your routes file to enable routes_path work properly.

Resources