Skip to content

Latest commit

 

History

History
141 lines (96 loc) · 1.87 KB

MigrationsFromV2.md

File metadata and controls

141 lines (96 loc) · 1.87 KB

[ Back to TheRole ]


Migration form TheRole 2 to TheRole 3

Gemfile

BEFORE

gem 'the_role', '~> 2.X'

or

gem 'the_role', '~> 2.X'
gem 'the_role_bootstrap3_ui'

AFTER

gem 'the_role', '~> 3.0'

or

gem 'the_role_api', '~> 3.0'
gem 'the_role_management_panel', '~> 3.0'

Change routing

config/routes.rb

before

  namespace :admin do
    TheRole::Routes.mixin(self)
  end

after

  TheRoleManagementPanel::Routes.mixin(self)

Change User model

before

class User < ActiveRecord::Base
  include TheRole::User
end

after

class User < ActiveRecord::Base
  include TheRole::Api::User
end

Change Role model

class Role < ActiveRecord::Base
  include TheRole::Role
end

after

class Role < ActiveRecord::Base
  include TheRole::Api::Role
end

Initializer

config/initializers/the_role.rb

before

TheRole.configure do |config|
  config.destroy_strategy  = nil
  config.default_user_role = :blogger
  config.layout            = :application
  config.first_user_should_be_admin = true
end

after

TheRole.configure do |config|
  # [ Devise => :authenticate_user! | Sorcery => :require_login ]
  config.login_required_method = :authenticate_user!

  # layout for Management panel
  config.layout = :the_role_management_panel

  config.default_user_role          = :blogger
  config.first_user_should_be_admin = true

  # config.access_denied_method       = :access_denied
  # config.destroy_strategy           = :nil
end

For PostgresSQL users

how to use native :json column


Bundle && restart

bundle
rails s

[ Back to TheRole ]