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

V3.0.0.alpha : running in production is breaking #3420

Closed
RocKhalil opened this issue Nov 16, 2021 · 8 comments
Closed

V3.0.0.alpha : running in production is breaking #3420

RocKhalil opened this issue Nov 16, 2021 · 8 comments
Milestone

Comments

@RocKhalil
Copy link
Contributor

For some reason, customizing actions ( or even including them ) in initializers/rails_admin.rb is breaking;

def add_action_custom_key(action, &block)
  action.instance_eval(&block) if block
  @@actions ||= []
  if action.custom_key.in?(@@actions.collect(&:custom_key))
    raise "Action #{action.custom_key} already exists. Please change its custom key."
  else
    @@actions << action
  end
end

Thrown error:

add_action_custom_key: Action dashboard already exists. Please change its custom key. (RuntimeError)
@mshibuya
Copy link
Member

How does you config/initializers/rails_admin.rb look like?

@RocKhalil
Copy link
Contributor Author

@mshibuya

RailsAdmin.config do |config|
  ### Popular gems integration

  ## == Devise ==
  config.authenticate_with do
    warden.authenticate! scope: :user
  end
  config.current_user_method(&:current_user)

  ## == Cancan ==
  # config.authorize_with :cancan

  config.parent_controller = '::ApplicationController'

  ## == Pundit ==
  # config.authorize_with :pundit

  ## == PaperTrail ==
  # config.audit_with :paper_trail, 'User', 'PaperTrail::Version' # PaperTrail >= 3.0.0

  ### More at https://github.com/sferik/rails_admin/wiki/Base-configuration

  ## == Gravatar integration ==
  ## To disable Gravatar integration in Navigation Bar set to false
  # config.show_gravatar = true

  config.actions do
    dashboard do
      statistics false # to disable the models load
    end

    index # mandatory

    new do
      except [
        UserAction,
        SystemLog,
        Song, SongAction, SongStat, SongStatsExternal
      ]
    end

    export

    bulk_delete do
      except [
        User,
        UserAction,
        SystemLog,
        SongAction, SongStat, SongStatsExternal
      ]
    end

    show

    edit do
      except [
        UserAction,
        SystemLog,
        SongAction, SongStat, SongStatsExternal
      ]
    end

    delete do
      except [
        User,
        UserAction,
        SystemLog,
        SongAction, SongStat, SongStatsExternal
      ]
    end

    show_in_app
    ## With an audit adapter, you can add:
    # history_index
    # history_show

    I18n.load_path += Dir["#{Rails.root}/lib/rails_admin/locales/*.yml"]
    Dir["#{Rails.root}/lib/rails_admin/actions/*.rb"].map { |f| [f, require(f)] }
    Dir["#{Rails.root}/lib/rails_admin/configuration/*.rb"].map { |f| [f, require(f)] }

    %i[approved live expired not_a_fit].each do |status|
      eval(''"
        song_status_update_#{status} do
          only [Song]
        end
      "'')
    end

    %i[claimed released].each do |status|
      eval(''"
        song_match_status_update_#{status} do
          only [SongMatch]
        end
      "'')
    end
  end
end

This works fine with Version 2.X

@mshibuya
Copy link
Member

Hmm I can't reproduce locally...
Could you provide the full stack trace of this error?

add_action_custom_key: Action dashboard already exists. Please change its custom key. (RuntimeError)

@RocKhalil
Copy link
Contributor Author

Did you try to run it with RAILS_ENV=production ? it's working on dev environment but not on production

@RocKhalil
Copy link
Contributor Author

Basically, the add_action_custom_key error shows for dashboard, new, index etc... ( the main actions used by rails admin )

@mshibuya
Copy link
Member

mshibuya commented Nov 25, 2021

Thanks, I could reproduce. This issue should be related to this change, I'll investigate...
e4ae669

mshibuya added a commit that referenced this issue Nov 25, 2021
@mshibuya
Copy link
Member

Pushed a fix in a branch, could you try it by putting

gem 'rails_admin', github: 'railsadminteam/rails_admin', branch: 'fix-initialization'

into your Gemfile?

@RocKhalil
Copy link
Contributor Author

Works perfectly !
Thanks for the quick fix

@mshibuya mshibuya added this to the 3.0.0 milestone Dec 11, 2021
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

2 participants