trestle
trestle copied to clipboard
How To: Secure Trestle with Devise Not Work
Hello.
I am using trestle-auth gem. That's all nice.
I want to be secure Trestle with Devise gem.
I installed devise gem and read wiki(How To: Secure Trestle with Devise) section.
But I get error following:
~/r/customer_management ❯❯❯ bundle exec rails s -p 3001 ⏎ feature/add-student-must-info ✱ ◼
=> Booting Puma
=> Rails 5.2.2 application starting in development
=> Run `rails server -h` for more startup options
Exiting
Traceback (most recent call last):
89: from bin/rails:4:in `<main>'
88: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `require'
87: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:257:in `load_dependency'
86: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `block in require'
85: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
84: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
83: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
82: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
81: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
80: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/railties-5.2.2/lib/rails/commands.rb:18:in `<main>'
79: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/railties-5.2.2/lib/rails/command.rb:46:in `invoke'
78: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/railties-5.2.2/lib/rails/command/base.rb:65:in `perform'
77: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
76: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
75: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
74: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/railties-5.2.2/lib/rails/commands/server/server_command.rb:142:in `perform'
73: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/railties-5.2.2/lib/rails/commands/server/server_command.rb:142:in `tap'
72: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/railties-5.2.2/lib/rails/commands/server/server_command.rb:147:in `block in perform'
71: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/railties-5.2.2/lib/rails/commands/server/server_command.rb:51:in `start'
70: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/railties-5.2.2/lib/rails/commands/server/server_command.rb:89:in `log_to_stdout'
69: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/rack-2.0.6/lib/rack/server.rb:354:in `wrapped_app'
68: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/railties-5.2.2/lib/rails/commands/server/server_command.rb:27:in `app'
67: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/rack-2.0.6/lib/rack/server.rb:219:in `app'
66: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/rack-2.0.6/lib/rack/server.rb:319:in `build_app_and_options_from_config'
65: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/rack-2.0.6/lib/rack/builder.rb:40:in `parse_file'
64: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/rack-2.0.6/lib/rack/builder.rb:49:in `new_from_string'
63: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/rack-2.0.6/lib/rack/builder.rb:49:in `eval'
62: from config.ru:in `<main>'
61: from config.ru:in `new'
60: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/rack-2.0.6/lib/rack/builder.rb:55:in `initialize'
59: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/rack-2.0.6/lib/rack/builder.rb:55:in `instance_eval'
58: from config.ru:3:in `block in <main>'
57: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:44:in `require_relative'
56: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `require'
55: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:257:in `load_dependency'
54: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `block in require'
53: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
52: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
51: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
50: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
49: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
48: from /Users/hiro2/rails_projects/customer_management/config/environment.rb:5:in `<main>'
47: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/railties-5.2.2/lib/rails/application.rb:361:in `initialize!'
46: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/railties-5.2.2/lib/rails/initializable.rb:60:in `run_initializers'
45: from /Users/hiro2/.rbenv/versions/2.6.0/lib/ruby/2.6.0/tsort.rb:205:in `tsort_each'
44: from /Users/hiro2/.rbenv/versions/2.6.0/lib/ruby/2.6.0/tsort.rb:226:in `tsort_each'
43: from /Users/hiro2/.rbenv/versions/2.6.0/lib/ruby/2.6.0/tsort.rb:347:in `each_strongly_connected_component'
42: from /Users/hiro2/.rbenv/versions/2.6.0/lib/ruby/2.6.0/tsort.rb:347:in `call'
41: from /Users/hiro2/.rbenv/versions/2.6.0/lib/ruby/2.6.0/tsort.rb:347:in `each'
40: from /Users/hiro2/.rbenv/versions/2.6.0/lib/ruby/2.6.0/tsort.rb:349:in `block in each_strongly_connected_component'
39: from /Users/hiro2/.rbenv/versions/2.6.0/lib/ruby/2.6.0/tsort.rb:415:in `each_strongly_connected_component_from'
38: from /Users/hiro2/.rbenv/versions/2.6.0/lib/ruby/2.6.0/tsort.rb:415:in `call'
37: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/railties-5.2.2/lib/rails/initializable.rb:50:in `tsort_each_child'
36: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/railties-5.2.2/lib/rails/initializable.rb:50:in `each'
35: from /Users/hiro2/.rbenv/versions/2.6.0/lib/ruby/2.6.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
34: from /Users/hiro2/.rbenv/versions/2.6.0/lib/ruby/2.6.0/tsort.rb:431:in `each_strongly_connected_component_from'
33: from /Users/hiro2/.rbenv/versions/2.6.0/lib/ruby/2.6.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
32: from /Users/hiro2/.rbenv/versions/2.6.0/lib/ruby/2.6.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
31: from /Users/hiro2/.rbenv/versions/2.6.0/lib/ruby/2.6.0/tsort.rb:228:in `block in tsort_each'
30: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/railties-5.2.2/lib/rails/initializable.rb:61:in `block in run_initializers'
29: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/railties-5.2.2/lib/rails/initializable.rb:32:in `run'
28: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/railties-5.2.2/lib/rails/initializable.rb:32:in `instance_exec'
27: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/railties-5.2.2/lib/rails/engine.rb:613:in `block in <class:Engine>'
26: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/railties-5.2.2/lib/rails/engine.rb:613:in `each'
25: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/railties-5.2.2/lib/rails/engine.rb:614:in `block (2 levels) in <class:Engine>'
24: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/railties-5.2.2/lib/rails/engine.rb:656:in `load_config_initializer'
23: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.2/lib/active_support/notifications.rb:170:in `instrument'
22: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/railties-5.2.2/lib/rails/engine.rb:657:in `block in load_config_initializer'
21: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:285:in `load'
20: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:257:in `load_dependency'
19: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:285:in `block in load'
18: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:50:in `load'
17: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:50:in `load'
16: from /Users/hiro2/rails_projects/customer_management/config/initializers/trestle.rb:1:in `<main>'
15: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/trestle-0.8.11/lib/trestle.rb:57:in `configure'
14: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/trestle-0.8.11/lib/trestle/configurable.rb:12:in `configure'
13: from /Users/hiro2/rails_projects/customer_management/config/initializers/trestle.rb:244:in `block in <main>'
12: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `require'
11: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:257:in `load_dependency'
10: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `block in require'
9: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
8: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
7: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
6: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
5: from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
4: from /Users/hiro2/rails_projects/customer_management/lib/trestle-devise/controller_methods.rb:1:in `<main>'
3: from /Users/hiro2/rails_projects/customer_management/lib/trestle-devise/controller_methods.rb:2:in `<module:Trestle>'
2: from /Users/hiro2/rails_projects/customer_management/lib/trestle-devise/controller_methods.rb:3:in `<module:Auth>'
1: from /Users/hiro2/rails_projects/customer_management/lib/trestle-devise/controller_methods.rb:6:in `<module:ControllerMethods>'
/Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.2/lib/active_support/concern.rb:128:in `included': Cannot define multiple 'included' blocks for a Concern (ActiveSupport::Concern::MultipleIncludedBlocks)
config/initializers/trestle.rb
Trestle.configure do |config|
# == Customization Options
#
# Set the page title shown in the main header within the admin.
#
config.site_title = "xxxxxxxxxxxx"
# Specify a custom image to be used in place of the site title for mobile and
# expanded/desktop navigation. These images should be placed within your
# asset paths, e.g. app/assets/images.
#
# config.site_logo = "logo.png"
# Specify a custom image to be used for the collapsed/tablet navigation.
#
# config.site_logo_small = "logo-small.png"
# Set the text shown in the page footer within the admin.
# Defaults to 'Powered by Trestle'.
#
config.footer = "Powered by AndNature"
# Sets the default precision for timestamps (either :minutes or :seconds).
# Defaults to :minutes.
#
# config.timestamp_precision = :minutes
# == Mounting Options
#
# Set the path at which to mount the Trestle admin. Defaults to /admin.
#
# config.path = "/admin"
# Toggle whether Trestle should automatically mount the admin within your
# Rails application's routes. Defaults to true.
#
# config.automount = false
# == Navigation Options
#
# Set the path to consider the application root (for title links and breadcrumbs).
# Defaults to the same value as `config.path`.
#
# config.root = "/"
# Set the initial breadcrumbs to display in the breadcrumb trail.
# Defaults to a breadcrumb labeled 'Home' linking to to the application root.
#
# config.root_breadcrumbs = -> { [Trestle::Breadcrumb.new("Home", Trestle.config.root)] }
# Set the default icon class to use when it is not explicitly provided.
# Defaults to "fa fa-arrow-circle-o-right".
#
# config.default_navigation_icon = "fa fa-arrow-circle-o-right"
# Add an explicit menu block to be added to the admin navigation.
#
# config.menu do
# group "Custom Group" do
# item "Custom Link", "/admin/custom", icon: "fa fa-car", badge: { text: "NEW!", class: "label-success" }, priority: :first
# end
# end
# == Extension Options
#
# Specify helper modules to expose to the admin.
#
# config.helper :all
# Register callbacks to run before, after or around all Trestle actions.
#
# config.before_action do |controller|
# Rails.logger.debug("Before action")
# end
#
# config.after_action do |controller|
# Rails.logger.debug("After action")
# end
#
# config.around_action do |controller, block|
# Rails.logger.debug("Around action (before)")
# block.call
# Rails.logger.debug("Around action (after)")
# end
# Specify a custom hook to be injected into the admin.
#
# config.hook(:stylesheets) do
# stylesheet_link_tag "custom"
# end
# Optional, but it is always nice to give folks the option of
# logging out:
config.hook("view.header") do
render "admin/header"
end
# Toggle whether Turbolinks is enabled within the admin.
# Defaults to true if Turbolinks is available.
#
# config.turbolinks = false
# Specify the parameters that should persist across requests when
# paginating or reordering. Defaults to [:sort, :order, :scope].
#
# config.persistent_params << :query
# Customize the default adapter class used by all admin resources.
# See the documentation on Trestle::Adapters::Adapter for details on
# the adapter methods that can be customized.
#
# config.default_adapter = Trestle::Adapters.compose(Trestle::Adapters::SequelAdapter)
# config.default_adapter.include MyAdapterExtensions
# Register a form field type to be made available to the Trestle form builder.
# Field types should conform to the following method definition:
#
# class CustomFormField
# def initialize(builder, template, name, options={}, &block); end
# def render; end
# end
#
# config.form_field :custom, CustomFormField
# == Debugging Options
#
# Enable debugging of form errors. Defaults to true in development mode.
#
# config.debug_form_errors = true
# == Authentication Options
#
# Specify the user class to be used by trestle-auth.
#
config.auth.user_class = -> { Administrator }
# Specify the scope for valid admin users.
# Defaults to config.auth.user_class (unscoped).
#
# config.auth.user_scope = -> { User.where(admin: true) }
# Specify the Trestle admin for managing administrator users.
#
config.auth.user_admin = -> { :"auth/administrators" }
# Specify the parameter (along with a password) to be used to
# authenticate an administrator. Defaults to :email.
#
# config.auth.authenticate_with = :login
# Customize the method for authenticating a user given login parameters.
# The block should return an instance of the auth user class, or nil.
#
# config.auth.authenticate = ->(params) {
# User.authenticate(params[:login], params[:password])
# }
# Customize the method for finding a user given an ID from the session.
# The block should return an instance of the auth user class, or nil.
#
# config.auth.find_user = ->(id) {
# User.find_by(id: id)
# }
# Customize the rendering of user avatars. Can be disabled by setting to false.
# Defaults to the Gravatar based on the user's email address.
#
# config.auth.avatar = ->(user) {
# avatar(fallback: user.initials) do
# image_tag(user.avatar_url, alt: user.name) if user.avatar_url?
# end
# }
# Customize the rendering of the current user's name in the main header.
# Defaults to the user's #first_name and #last_name (last name in bold),
# with a fallback to `display(user)` if those methods aren't defined.
#
config.auth.format_user_name = ->(user) {
if user.respond_to?(:first_name) && user.respond_to?(:last_name)
safe_join([user.last_name, content_tag(:strong, user.first_name)], " ")
else
display(user)
end
}
# Customize the method for determining the user's locale.
# Defaults to user.locale (if the method is defined).
#
# config.auth.locale = ->(user) {
# user.locale if user.respond_to?(:locale)
# }
# Customize the method for determining the user's time zone.
# Defaults to user.time_zone (if the method is defined).
#
# config.auth.time_zone = ->(user) {
# user.time_zone if user.respond_to?(:time_zone)
# }
# Specify the redirect location after a successful login.
# Defaults to the main Trestle admin path.
#
# config.auth.redirect_on_login = -> {
# if admin = Trestle.lookup(Trestle.config.auth.user_admin)
# admin.instance_path(current_user)
# else
# Trestle.config.path
# end
# }
# Specify the redirect location after logging out.
# Defaults to the trestle-auth new login path.
#
# config.auth.redirect_on_logout = -> { "/" }
# Enable or disable remember me functionality. Defaults to true.
#
# config.auth.remember.enabled = false
# Specify remember me expiration time. Defaults to 2 weeks.
#
# config.auth.remember.for = 30.days
# Customize the method for authenticating a user given a remember token.
#
# config.auth.remember.authenticate = ->(token) {
# User.authenticate_with_remember_token(token)
# }
# Customize the method for remembering a user.
#
# config.auth.remember.remember_me, ->(user) { user.remember_me! }
# Customize the method for forgetting a user.
#
# config.auth.remember.forget_me, ->(user) { user.forget_me! }
# Customize the method for generating the remember cookie.
#
# config.auth.remember.cookie, ->(user) {
# { value: user.remember_token, expires: user.remember_token_expires_at }
# }
require 'trestle-devise/controller_methods'
Trestle::ApplicationController.send(:include, Trestle::Auth::ControllerMethods)
end
lib/trestle-devise/controller_methods.rb
module Trestle
module Auth
module ControllerMethods
extend ActiveSupport::Concern
included do
before_action :authenticate_administrators!
before_action :require_president!
end
protected
def require_president!
redirect_to root_url, alert: "Only the president is authorized to access this area" unless current_administrators.roles?(:admin)
end
end
end
end
Gemfile
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.6.0'
gem 'rails', '~> 5.2.2'
gem 'sqlite3'
gem 'puma', '~> 3.11'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.2'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.5'
gem 'trestle'
gem 'trestle-auth'
gem 'trestle-search'
gem 'trestle-simplemde'
gem 'devise'
gem 'slim-rails'
gem 'rails-i18n', '~> 5.1'
gem 'bootsnap', '>= 1.1.0', require: false
group :production do
gem 'pg'
end
group :development, :test do
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'pry-rails'
gem 'pry-byebug'
gem 'pry-doc'
gem 'rspec-rails'
gem 'factory_bot_rails'
gem 'rails-controller-testing'
end
group :development do
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
group :test do
gem 'capybara', '>= 2.15'
gem 'selenium-webdriver'
gem 'chromedriver-helper'
end
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
What's the matter?
I don't understand:
- if I use devise gem, trestle-auth gem do not need?
- Trestle gem covered what Ruby and Rails version.
- how to integrate trestle-auth and devise gem. I want to know integrate process.
I'm not good at English. I'm sorry for my poor English.
Thank you.
HI @HiroshiSano0711 , I believe these lines:
require 'trestle-devise/controller_methods'
Trestle::ApplicationController.send(:include, Trestle::Auth::ControllerMethods)
should go outside your config block. I've updated the wiki to reflect this.
Let us know how it goes!
Hi @nathancolgate , thank you for reply and updating the wiki.
I moved these lines outside config block:
require 'trestle-devise/controller_methods'
Trestle::ApplicationController.send(:include, Trestle::Auth::ControllerMethods)
I start Rails server, but I got same error.
I check config/initializers/trestle.rb with pry .
~/r/customer_management ❯❯❯ bundle exec rails s ⏎ feature/fix-footer-design ✭ ✱ ◼
=> Booting Puma
=> Rails 5.2.2 application starting in development
=> Run `rails server -h` for more startup options
gem install awesome_print # <-- highly recommended
From: /Users/hiro2/rails_projects/customer_management/config/initializers/trestle.rb @ line 240 :
235: # { value: user.remember_token, expires: user.remember_token_expires_at }
236: # }
237: end
238:
239: binding.pry
=> 240: require 'trestle-devise/controller_methods'
241: Trestle::ApplicationController.send(:include, Trestle::Auth::ControllerMethods)
2.6.0 (main):0 > require 'trestle-devise/controller_methods'
ActiveSupport::Concern::MultipleIncludedBlocks: Cannot define multiple 'included' blocks for a Concern
from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.2/lib/active_support/concern.rb:128:in `included'
I try to remove bootsnap cache(delete /tmp/cache/bootsnap-load-path-cache and tmp/cache/bootsnap-compile-cache)
After removing, I try to start rails server again.
But I got same error...😓
ActiveSupport::Concern::MultipleIncludedBlocks: Cannot define multiple 'included' blocks for a Concern
from /Users/hiro2/rails_projects/customer_management/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.2/lib/active_support/concern.rb:128:in `included'
I seem that error occur this line(in lib/trestle-devise/controller_methods)🤔
included do
before_action :authenticate_user!
before_action :require_president!
end
Had the same issue and it was because I was using trestle-sidekiq that has a dependency on trestle-auth, and trestle auth already defines Trestle::Auth::ControllerMethods
ActiveSupport::Concern::MultipleIncludedBlocks: Cannot define multiple 'included' blocks for a Concern
I fixed this error removing the require and putting the file in the autoinclude path. But still.