Redmine give this error in production.log

DEPRECATION WARNING: Using a dynamic :action segment in a route is deprecated and will be removed in Rails 6.0. (called from instance_eval at /home/redmine/4.11/config/routes.rb:370)
DEPRECATION WARNING: Using a dynamic :action segment in a route is deprecated and will be removed in Rails 6.0. (called from instance_eval at /home/redmine/4.11/config/routes.rb:370)
DEPRECATION WARNING: Using a dynamic :action segment in a route is deprecated and will be removed in Rails 6.0. (called from instance_eval at /home/redmine/4.11/config/routes.rb:370)
DEPRECATION WARNING: Using a dynamic :action segment in a route is deprecated and will be removed in Rails 6.0. (called from instance_eval at /home/redmine/4.11/config/routes.rb:370)
DEPRECATION WARNING: Using a dynamic :action segment in a route is deprecated and will be removed in Rails 6.0. (called from instance_eval at /home/redmine/4.11/config/routes.rb:370)
DEPRECATION WARNING: Using a dynamic :action segment in a route is deprecated and will be removed in Rails 6.0. (called from instance_eval at /home/redmine/4.11/config/routes.rb:370)
DEPRECATION WARNING: Using a dynamic :action segment in a route is deprecated and will be removed in Rails 6.0. (called from instance_eval at /home/redmine/4.11/config/routes.rb:370)

what this mean and how i can resolve this?

 366  Dir.glob File.expand_path("#{Redmine::Plugin.directory}/*") do |plugin_dir|
 367 file = File.join(plugin_dir, "config/routes.rb")
 368   if File.exists?(file)
 369      begin
 370       instance_eval File.read(file)
 371   rescue SyntaxError, StandardError => e
 372       puts "An error occurred while loading the routes definition of #{File.basename(plugin_dir)}   372  plugin (#{file}): #{e.message}."
373        exit 1
374      end
Ruby version 2.6.6-p146 (2020-03-31) [x86_64-linux]
Rails version 5.2.4.2

It means exactly what it says. It’s a warning that the dynamic :action segment you’re using will be removed in Rails v6.

im try this code for in end for all my plugins routes.rb but still give same error

any solution?? for these errors

@rafaelfranca can u help me plz??

  match 'contacts/:contact_id/duplicates' => 'contacts_duplicates#index', :via => [:get, :post]

  match 'projects/:project_id/deal_categories/new' => 'deal_categories#new', :via => [:get, :post]


  match 'auto_completes/taggable_tags' => 'auto_completes#taggable_tags', :via => :get, :as => 'auto_complete_taggable_tags'
  match 'auto_completes/contact_tags' => 'auto_completes#contact_tags', :via => :get, :as => 'auto_complete_contact_tags'
  match 'auto_completes/contacts' => 'auto_completes#contacts', :via => :get, :as => 'auto_complete_contacts'
  match 'auto_completes/companies' => 'auto_completes#companies', :via => :get, :as => 'auto_complete_companies'
  match 'auto_completes/deals' => 'auto_completes#deals', :via => :get, :as => 'auto_complete_deals'

  match 'users/new_from_contact/:id' => 'users#new_from_contact', :via => :get
  match 'contacts_duplicates/:action' => 'contacts_duplicates', :via => [:get, :post]
  match 'contacts_duplicates/search' => 'contacts_duplicates#search', :via => :get, :as => 'contacts_duplicates_search'
  match 'contacts_issues/:action' => 'contacts_issues', :via => [:get, :post, :delete, :put]
  match 'contacts_vcf/:action' => 'contacts_vcf', :via => [:get, :post]
  match 'deal_contacts/:action' => 'deal_contacts', :via => [:get, :post, :delete]
  match 'deals_tasks/:action' => 'deals_tasks', :via => [:get, :post, :put]
  match 'contacts_settings/:action' => 'contacts_settings', :via => [:get, :post]
  match 'contacts_mail_handler/:action' => 'contacts_mail_handler', :via => [:get, :post]
  match 'attachments/contacts_thumbnail/:id(/:size)', :controller => 'attachments', :action => 'contacts_thumbnail', :id => /\d+/, :via => :get
  namespace :integrations do
  namespace 'stripe' do
    %w(auth webhook activate).each do |action|
      get action, action: action
    end
  end
  post 'stripe/deactivate', controller: 'stripe', action: 'deactivate'
end

You still have many routes that define a dynamic :action segment in your code, like the one below:

  match 'contacts_vcf/:action' => 'contacts_vcf', :via => [:get, :post]`

You should change all of them to be explicit ones like in the SO link sent by @nolyoi.

2 Likes

They are not errors. Deprecation warnings are only a concern if you want to be running the latest version of rails. Generally, this is only relevant if you’re a project (Redmine) developer and you don’t seem to be. – H

1 Like

This.

Also, in get action, action: action you can leave out the action: action, since Rails defaults to the action with the same name as the get.

Ex:

namespace 'stripe' do
    %w(auth webhook activate).each do |action|
      get action, action: action
    end
  end

to this:

namespace 'stripe' do
    %w(auth webhook activate).each do |action|
      get action
    end
  end
1 Like
Creating scope :sorted. Overwriting existing method Group.sorted.
Creating scope :sorted. Overwriting existing method User.sorted.
Creating scope :having_mail. Overwriting existing method User.having_mail.
Creating scope :system. Overwriting existing method Enumeration.system.
DEPRECATION WARNING: Using a dynamic :action segment in a route is deprecated and will be removed in Rails 6.0. (called from instance_eval at /home/redmine/4.11/config/routes.rb:370)
DEPRECATION WARNING: Using a dynamic :action segment in a route is deprecated and will be removed in Rails 6.0. (called from instance_eval at /home/redmine/4.11/config/routes.rb:370)
DEPRECATION WARNING: Using a dynamic :action segment in a route is deprecated and will be removed in Rails 6.0. (called from instance_eval at /home/redmine/4.11/config/routes.rb:370)
DEPRECATION WARNING: Using a dynamic :action segment in a route is deprecated and will be removed in Rails 6.0. (called from instance_eval at /home/redmine/4.11/config/routes.rb:370)
DEPRECATION WARNING: Using a dynamic :action segment in a route is deprecated and will be removed in Rails 6.0. (called from instance_eval at /home/redmine/4.11/config/routes.rb:370)
DEPRECATION WARNING: Using a dynamic :action segment in a route is deprecated and will be removed in Rails 6.0. (called from instance_eval at /home/redmine/4.11/config/routes.rb:370)
DEPRECATION WARNING: Using a dynamic :action segment in a route is deprecated and will be removed in Rails 6.0. (called from instance_eval at /home/redmine/4.11/config/routes.rb:370)
Started HEAD "/" for 127.0.0.1 at 2020-09-24 01:55:19 +0300
Processing by WelcomeController#index as HTML
  Current user: anonymous

the output in my production.log

my config/routes.rb

  match 'contacts/:contact_id/duplicates' => 'contacts_duplicates#index', :via => [:get, :post]

  match 'projects/:project_id/deal_categories/new' => 'deal_categories#new', :via => [:get, :post]


  match 'auto_completes/taggable_tags' => 'auto_completes#taggable_tags', :via => :get, :as => 'auto_complete_taggable_tags'
  match 'auto_completes/contact_tags' => 'auto_completes#contact_tags', :via => :get, :as => 'auto_complete_contact_tags'
  match 'auto_completes/contacts' => 'auto_completes#contacts', :via => :get, :as => 'auto_complete_contacts'
  match 'auto_completes/companies' => 'auto_completes#companies', :via => :get, :as => 'auto_complete_companies'
  match 'auto_completes/deals' => 'auto_completes#deals', :via => :get, :as => 'auto_complete_deals'

  match 'users/new_from_contact/:id' => 'users#new_from_contact', :via => :get
  match 'contacts_duplicates/:action' => 'contacts_duplicates', :via => [:get, :post]
  match 'contacts_duplicates/search' => 'contacts_duplicates#search', :via => :get, :as => 'contacts_duplicates_search'
  match 'contacts_issues/:action' => 'contacts_issues', :via => [:get, :post, :delete, :put]
  match 'contacts_vcf/:action' => 'contacts_vcf', :via => [:get, :post]
  match 'deal_contacts/:action' => 'deal_contacts', :via => [:get, :post, :delete]
  match 'deals_tasks/:action' => 'deals_tasks', :via => [:get, :post, :put]
  match 'contacts_settings/:action' => 'contacts_settings', :via => [:get, :post]
  match 'contacts_mail_handler/:action' => 'contacts_mail_handler', :via => [:get, :post]
  match 'attachments/contacts_thumbnail/:id(/:size)', :controller => 'attachments', :action => 'contacts_thumbnail', :id => /\d+/, :via => :get
namespace :integrations do
  namespace 'stripe' do
    %w(auth webhook activate).each do |action|
      get action
    end
     post 'stripe/deactivate', controller: 'stripe', action: 'deactivate'
end
end

the problem still i give same error

im try the code but still same problem

Do you mean its not affects the program redmine? im read somthings its effect to Efficiency and speed??

@nolyoi nolyoi im try your code its still same error

@georgeclaghorn any solution???

@ashrafalzyoud your question has been asked and answered by many different people in this forum. In summary, people have told you:

  1. That any route in your routes.rb file that has an :action in the path match will show that warning,
  2. That the fix is to change those routes to use explicit actions
  3. That the error is a warning anyway, so it is mostly a concern if you are going to upgrade Rails versions.

I will have to ask you to stop tagging random people who have not been involved in the conversation please.

1 Like

The guidance in the Stackoverflow post was not to add the code:

namespace :integrations do
  namespace 'stripe' do
    %w(auth webhook activate).each do |action|
      get action
    end

    post 'stripe/deactivate', controller: 'stripe', action: 'deactivate'
  end
end

in your routes file as is, that was specific to the content in the question. You need to change all the routes in your application to use a similar thing, not use the same code.

1 Like