monarchy 1.1.5 → 2.0.0.pre.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +26 -0
  3. data/.gitignore +6 -6
  4. data/.rubocop.yml +3 -3
  5. data/CHANGELOG.md +11 -0
  6. data/Gemfile +4 -3
  7. data/Gemfile.lock +54 -53
  8. data/README.md +1 -0
  9. data/app/models/monarchy/hierarchy.rb +0 -1
  10. data/docs/acts_as_hierarchy.md +45 -0
  11. data/docs/acts_as_resource.md +103 -0
  12. data/docs/acts_as_user.md +52 -0
  13. data/docs/configuration.md +54 -0
  14. data/docs/installation.md +30 -0
  15. data/docs/usage.md +22 -0
  16. data/dummy/.rspec +2 -0
  17. data/dummy/README.rdoc +28 -0
  18. data/dummy/Rakefile +7 -0
  19. data/dummy/app/assets/images/.keep +0 -0
  20. data/dummy/app/assets/javascripts/application.js +13 -0
  21. data/dummy/app/assets/stylesheets/application.css +15 -0
  22. data/dummy/app/controllers/application_controller.rb +6 -0
  23. data/dummy/app/controllers/concerns/.keep +0 -0
  24. data/dummy/app/helpers/application_helper.rb +3 -0
  25. data/dummy/app/mailers/.keep +0 -0
  26. data/dummy/app/models/.keep +0 -0
  27. data/dummy/app/models/concerns/.keep +0 -0
  28. data/dummy/app/models/member.rb +4 -0
  29. data/dummy/app/models/memo.rb +5 -0
  30. data/dummy/app/models/project.rb +12 -0
  31. data/dummy/app/models/resource.rb +4 -0
  32. data/dummy/app/models/role.rb +4 -0
  33. data/dummy/app/models/status.rb +5 -0
  34. data/dummy/app/models/task.rb +5 -0
  35. data/dummy/app/models/user.rb +4 -0
  36. data/dummy/app/views/layouts/application.html.erb +14 -0
  37. data/dummy/bin/bundle +4 -0
  38. data/dummy/bin/rails +5 -0
  39. data/dummy/bin/rake +5 -0
  40. data/dummy/bin/setup +30 -0
  41. data/dummy/config/application.rb +25 -0
  42. data/dummy/config/boot.rb +6 -0
  43. data/dummy/config/database.yml +10 -0
  44. data/dummy/config/environment.rb +6 -0
  45. data/dummy/config/environments/development.rb +42 -0
  46. data/dummy/config/environments/production.rb +80 -0
  47. data/dummy/config/environments/test.rb +43 -0
  48. data/dummy/config/initializers/assets.rb +12 -0
  49. data/dummy/config/initializers/backtrace_silencers.rb +8 -0
  50. data/dummy/config/initializers/cookies_serializer.rb +4 -0
  51. data/dummy/config/initializers/filter_parameter_logging.rb +5 -0
  52. data/dummy/config/initializers/inflections.rb +17 -0
  53. data/dummy/config/initializers/mime_types.rb +5 -0
  54. data/dummy/config/initializers/monarchy.rb +46 -0
  55. data/dummy/config/initializers/session_store.rb +4 -0
  56. data/dummy/config/initializers/wrap_parameters.rb +15 -0
  57. data/dummy/config/locales/en.yml +23 -0
  58. data/dummy/config/routes.rb +57 -0
  59. data/dummy/config/secrets.yml +22 -0
  60. data/dummy/config.ru +5 -0
  61. data/dummy/db/migrate/20160220215254_monarchy_create_users.rb +7 -0
  62. data/dummy/db/migrate/20160221132205_monarchy_create_hierarchies.rb +22 -0
  63. data/dummy/db/migrate/20160221133215_monarchy_create_memberships.rb +38 -0
  64. data/dummy/db/migrate/20160221142305_create_memo_resource.rb +8 -0
  65. data/dummy/db/migrate/20160221142309_create_project_resource.rb +8 -0
  66. data/dummy/db/migrate/20160221154113_create_resource_resource.rb +8 -0
  67. data/dummy/db/migrate/20160306124820_add_memo_to_resource.rb +6 -0
  68. data/dummy/db/migrate/20160502212213_parent_as_setup.rb +7 -0
  69. data/dummy/db/migrate/20160815163909_task_model.rb +10 -0
  70. data/dummy/db/migrate/20160818205534_status.rb +9 -0
  71. data/dummy/db/schema.rb +111 -0
  72. data/dummy/lib/assets/.keep +0 -0
  73. data/dummy/public/404.html +67 -0
  74. data/dummy/public/422.html +67 -0
  75. data/dummy/public/500.html +66 -0
  76. data/dummy/public/favicon.ico +0 -0
  77. data/dummy/spec +1 -0
  78. data/lib/generators/templates/config.rb +44 -7
  79. data/lib/monarchy/acts_as_hierarchy.rb +12 -11
  80. data/lib/monarchy/acts_as_member.rb +8 -17
  81. data/lib/monarchy/acts_as_resource.rb +35 -22
  82. data/lib/monarchy/acts_as_user.rb +51 -39
  83. data/lib/monarchy/exceptions.rb +135 -0
  84. data/lib/monarchy/tasks.rb +1 -1
  85. data/lib/monarchy/validators.rb +83 -0
  86. data/lib/monarchy/version.rb +1 -1
  87. data/lib/monarchy.rb +21 -8
  88. data/monarchy.gemspec +4 -4
  89. metadata +85 -13
data/dummy/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
3
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4
+
5
+ require File.expand_path('../config/application', __FILE__)
6
+
7
+ Rails.application.load_tasks
File without changes
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+ class ApplicationController < ActionController::Base
3
+ # Prevent CSRF attacks by raising an exception.
4
+ # For APIs, you may want to use :null_session instead.
5
+ protect_from_forgery with: :exception
6
+ end
File without changes
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+ module ApplicationHelper
3
+ end
File without changes
File without changes
File without changes
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+ class Member < ActiveRecord::Base
3
+ acts_as_member
4
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+ class Memo < ActiveRecord::Base
3
+ acts_as_resource parent_as: :project
4
+ belongs_to :project
5
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+ class Project < ActiveRecord::Base
3
+ acts_as_resource parent_as: :resource
4
+ belongs_to :resource
5
+ has_one :status
6
+
7
+ after_create :create_status
8
+
9
+ def create_status
10
+ Status.create(project: self, name: 'Monarchy is OK!')
11
+ end
12
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+ class Resource < ActiveRecord::Base
3
+ acts_as_resource
4
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+ class Role < ActiveRecord::Base
3
+ acts_as_role
4
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+ class Status < ActiveRecord::Base
3
+ acts_as_resource parent_as: :project
4
+ belongs_to :project
5
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+ class Task < ActiveRecord::Base
3
+ acts_as_resource parent_as: :resource
4
+ belongs_to :resource, polymorphic: true
5
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+ class User < ActiveRecord::Base
3
+ acts_as_user
4
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6
+ <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
data/dummy/bin/bundle ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
4
+ load Gem.bin_path('bundler', 'bundle')
data/dummy/bin/rails ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
4
+ require_relative '../config/boot'
5
+ require 'rails/commands'
data/dummy/bin/rake ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ require_relative '../config/boot'
4
+ require 'rake'
5
+ Rake.application.run
data/dummy/bin/setup ADDED
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ require 'pathname'
4
+
5
+ # path to your application root.
6
+ APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
7
+
8
+ Dir.chdir APP_ROOT do
9
+ # This script is a starting point to setup your application.
10
+ # Add necessary setup steps to this file:
11
+
12
+ puts '== Installing dependencies =='
13
+ system 'gem install bundler --conservative'
14
+ system 'bundle check || bundle install'
15
+
16
+ # puts "\n== Copying sample files =="
17
+ # unless File.exist?("config/database.yml")
18
+ # system "cp config/database.yml.sample config/database.yml"
19
+ # end
20
+
21
+ puts "\n== Preparing database =="
22
+ system 'bin/rake db:setup'
23
+
24
+ puts "\n== Removing old logs and tempfiles =="
25
+ system 'rm -f log/*'
26
+ system 'rm -rf tmp/cache'
27
+
28
+ puts "\n== Restarting application server =="
29
+ system 'touch tmp/restart.txt'
30
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+ require File.expand_path('../boot', __FILE__)
3
+
4
+ require 'rails/all'
5
+
6
+ Bundler.require(*Rails.groups)
7
+
8
+ module Dummy
9
+ class Application < Rails::Application
10
+ # Settings in config/environments/* take precedence over those specified here.
11
+ # Application configuration should go into files in config/initializers
12
+ # -- all .rb files in that directory are automatically loaded.
13
+
14
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
15
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
16
+ # config.time_zone = 'Central Time (US & Canada)'
17
+
18
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
19
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
20
+ # config.i18n.default_locale = :de
21
+
22
+ # Do not swallow errors in after_commit/after_rollback callbacks.
23
+ config.active_record.raise_in_transactional_callbacks = true
24
+ end
25
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+ # Set up gems listed in the Gemfile.
3
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
4
+
5
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
6
+ $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,10 @@
1
+ test:
2
+ adapter: "sqlite3"
3
+ pool: 5
4
+ timeout: 5000
5
+ database: "db/test.sqlite3"
6
+ development:
7
+ adapter: "sqlite3"
8
+ pool: 5
9
+ timeout: 5000
10
+ database: "db/development.sqlite3"
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+ # Load the Rails application.
3
+ require File.expand_path('../application', __FILE__)
4
+
5
+ # Initialize the Rails application.
6
+ Rails.application.initialize!
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+ Rails.application.configure do
3
+ # Settings specified here will take precedence over those in config/application.rb.
4
+
5
+ # In the development environment your application's code is reloaded on
6
+ # every request. This slows down response time but is perfect for development
7
+ # since you don't have to restart the web server when you make code changes.
8
+ config.cache_classes = false
9
+
10
+ # Do not eager load code on boot.
11
+ config.eager_load = false
12
+
13
+ # Show full error reports and disable caching.
14
+ config.consider_all_requests_local = true
15
+ config.action_controller.perform_caching = false
16
+
17
+ # Don't care if the mailer can't send.
18
+ config.action_mailer.raise_delivery_errors = false
19
+
20
+ # Print deprecation notices to the Rails logger.
21
+ config.active_support.deprecation = :log
22
+
23
+ # Raise an error on page load if there are pending migrations.
24
+ config.active_record.migration_error = :page_load
25
+
26
+ # Debug mode disables concatenation and preprocessing of assets.
27
+ # This option may cause significant delays in view rendering with a large
28
+ # number of complex assets.
29
+ config.assets.debug = true
30
+
31
+ # Asset digests allow you to set far-future HTTP expiration dates on all assets,
32
+ # yet still be able to expire them through the digest params.
33
+ config.assets.digest = true
34
+
35
+ # Adds additional error checking when serving assets at runtime.
36
+ # Checks for improperly declared sprockets dependencies.
37
+ # Raises helpful error messages.
38
+ config.assets.raise_runtime_errors = true
39
+
40
+ # Raises error for missing translations
41
+ # config.action_view.raise_on_missing_translations = true
42
+ end
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+ Rails.application.configure do
3
+ # Settings specified here will take precedence over those in config/application.rb.
4
+
5
+ # Code is not reloaded between requests.
6
+ config.cache_classes = true
7
+
8
+ # Eager load code on boot. This eager loads most of Rails and
9
+ # your application in memory, allowing both threaded web servers
10
+ # and those relying on copy on write to perform better.
11
+ # Rake tasks automatically ignore this option for performance.
12
+ config.eager_load = true
13
+
14
+ # Full error reports are disabled and caching is turned on.
15
+ config.consider_all_requests_local = false
16
+ config.action_controller.perform_caching = true
17
+
18
+ # Enable Rack::Cache to put a simple HTTP cache in front of your application
19
+ # Add `rack-cache` to your Gemfile before enabling this.
20
+ # For large-scale production use, consider using a caching reverse proxy like
21
+ # NGINX, varnish or squid.
22
+ # config.action_dispatch.rack_cache = true
23
+
24
+ # Disable serving static files from the `/public` folder by default since
25
+ # Apache or NGINX already handles this.
26
+ config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
27
+
28
+ # Compress JavaScripts and CSS.
29
+ config.assets.js_compressor = :uglifier
30
+ # config.assets.css_compressor = :sass
31
+
32
+ # Do not fallback to assets pipeline if a precompiled asset is missed.
33
+ config.assets.compile = false
34
+
35
+ # Asset digests allow you to set far-future HTTP expiration dates on all assets,
36
+ # yet still be able to expire them through the digest params.
37
+ config.assets.digest = true
38
+
39
+ # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
40
+
41
+ # Specifies the header that your server uses for sending files.
42
+ # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
43
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
44
+
45
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
46
+ # config.force_ssl = true
47
+
48
+ # Use the lowest log level to ensure availability of diagnostic information
49
+ # when problems arise.
50
+ config.log_level = :debug
51
+
52
+ # Prepend all log lines with the following tags.
53
+ # config.log_tags = [ :subdomain, :uuid ]
54
+
55
+ # Use a different logger for distributed setups.
56
+ # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
57
+
58
+ # Use a different cache store in production.
59
+ # config.cache_store = :mem_cache_store
60
+
61
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
62
+ # config.action_controller.asset_host = 'http://assets.example.com'
63
+
64
+ # Ignore bad email addresses and do not raise email delivery errors.
65
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
66
+ # config.action_mailer.raise_delivery_errors = false
67
+
68
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
69
+ # the I18n.default_locale when a translation cannot be found).
70
+ config.i18n.fallbacks = true
71
+
72
+ # Send deprecation notices to registered listeners.
73
+ config.active_support.deprecation = :notify
74
+
75
+ # Use default logging formatter so that PID and timestamp are not suppressed.
76
+ config.log_formatter = ::Logger::Formatter.new
77
+
78
+ # Do not dump schema after migrations.
79
+ config.active_record.dump_schema_after_migration = false
80
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+ Rails.application.configure do
3
+ # Settings specified here will take precedence over those in config/application.rb.
4
+
5
+ # The test environment is used exclusively to run your application's
6
+ # test suite. You never need to work with it otherwise. Remember that
7
+ # your test database is "scratch space" for the test suite and is wiped
8
+ # and recreated between test runs. Don't rely on the data there!
9
+ config.cache_classes = true
10
+
11
+ # Do not eager load code on boot. This avoids loading your whole application
12
+ # just for the purpose of running a single test. If you are using a tool that
13
+ # preloads Rails for running tests, you may have to set it to true.
14
+ config.eager_load = false
15
+
16
+ # Configure static file server for tests with Cache-Control for performance.
17
+ config.serve_static_files = true
18
+ config.static_cache_control = 'public, max-age=3600'
19
+
20
+ # Show full error reports and disable caching.
21
+ config.consider_all_requests_local = true
22
+ config.action_controller.perform_caching = false
23
+
24
+ # Raise exceptions instead of rendering exception templates.
25
+ config.action_dispatch.show_exceptions = false
26
+
27
+ # Disable request forgery protection in test environment.
28
+ config.action_controller.allow_forgery_protection = false
29
+
30
+ # Tell Action Mailer not to deliver emails to the real world.
31
+ # The :test delivery method accumulates sent emails in the
32
+ # ActionMailer::Base.deliveries array.
33
+ config.action_mailer.delivery_method = :test
34
+
35
+ # Randomize the order test cases are executed.
36
+ config.active_support.test_order = :random
37
+
38
+ # Print deprecation notices to the stderr.
39
+ config.active_support.deprecation = :stderr
40
+
41
+ # Raises error for missing translations
42
+ # config.action_view.raise_on_missing_translations = true
43
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+ # Be sure to restart your server when you modify this file.
3
+
4
+ # Version of your assets, change this if you want to expire all your assets.
5
+ Rails.application.config.assets.version = '1.0'
6
+
7
+ # Add additional assets to the asset load path
8
+ # Rails.application.config.assets.paths << Emoji.images_path
9
+
10
+ # Precompile additional assets.
11
+ # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
12
+ # Rails.application.config.assets.precompile += %w( search.js )
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+ # Be sure to restart your server when you modify this file.
3
+
4
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
5
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
6
+
7
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
8
+ # Rails.backtrace_cleaner.remove_silencers!
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+ # Be sure to restart your server when you modify this file.
3
+
4
+ Rails.application.config.action_dispatch.cookies_serializer = :json
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+ # Be sure to restart your server when you modify this file.
3
+
4
+ # Configure sensitive parameters which will be filtered from the log file.
5
+ Rails.application.config.filter_parameters += [:password]
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+ # Be sure to restart your server when you modify this file.
3
+
4
+ # Add new inflection rules using the following format. Inflections
5
+ # are locale specific, and you may define rules for as many different
6
+ # locales as you wish. All of these examples are active by default:
7
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
8
+ # inflect.plural /^(ox)$/i, '\1en'
9
+ # inflect.singular /^(ox)en/i, '\1'
10
+ # inflect.irregular 'person', 'people'
11
+ # inflect.uncountable %w( fish sheep )
12
+ # end
13
+
14
+ # These inflection rules are supported but not enabled by default:
15
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
16
+ # inflect.acronym 'RESTful'
17
+ # end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+ # Be sure to restart your server when you modify this file.
3
+
4
+ # Add new mime types for use in respond_to blocks:
5
+ # Mime::Type.register "text/richtext", :rtf
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+ Monarchy.configure do |config|
3
+ # REQUIRED SETTINGS
4
+
5
+ # You have to define which role will be the default one (read only) during inheritance.
6
+ # Example role: :guest
7
+ # Real case on resources:
8
+ # project: (you have no roles)
9
+ # section: (you have no roles)
10
+ # task: (you have a member role here)
11
+ # When you ask for user.roles_for(project) you will get a default role (:guest)
12
+ # in case when member role has inherited flag set to true
13
+ # Remember to create that role before setting it up eg:
14
+ # Monarchy::Role.create(name: :guest, inherited: false, level: 0)
15
+ config.inherited_default_role = :guest # symbol
16
+
17
+ # You have to define user class name or an actor class which respond to acts_as_user in your model.
18
+ # Example of model:
19
+ # class User < ActiveRecord::Base
20
+ # acts_as_user
21
+ # end
22
+ config.user_class_name = 'User' # string
23
+
24
+ # OPTIONAL SETTINGS
25
+
26
+ # If you want to override Member or Role class you have add correct actors to class definition
27
+ # Available: acts_as_member, acts_as_role
28
+ # Example:
29
+ # class Member < ActiveRecord::Base
30
+ # acts_as_member
31
+ # end
32
+ config.member_class_name = 'Member' # string
33
+ config.role_class_name = 'Role' # string
34
+
35
+ # If this option is setup to true all members bellow the destroying one, will be deleted.
36
+ config.members_access_revoke = true # boolean
37
+
38
+ # Set the revoke strategy using during '#revoke_role!' method
39
+ # Available: :revoke_member, :revoke_access
40
+ # Default: :revoke_member
41
+ # Info:
42
+ # :revoke_member - after revoking the last role from user's member remove the member
43
+ # :revoke_member - after revoking the last role from user's member
44
+ # remove the member, and all members bellow which belongs to the user
45
+ config.revoke_strategy = :revoke_member # symbol
46
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+ # Be sure to restart your server when you modify this file.
3
+
4
+ Rails.application.config.session_store :cookie_store, key: '_dummy_session'
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+ # Be sure to restart your server when you modify this file.
3
+
4
+ # This file contains settings for ActionController::ParamsWrapper which
5
+ # is enabled by default.
6
+
7
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
8
+ ActiveSupport.on_load(:action_controller) do
9
+ wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
10
+ end
11
+
12
+ # To enable root element in JSON for ActiveRecord objects.
13
+ # ActiveSupport.on_load(:active_record) do
14
+ # self.include_root_in_json = true
15
+ # end
@@ -0,0 +1,23 @@
1
+ # Files in the config/locales directory are used for internationalization
2
+ # and are automatically loaded by Rails. If you want to use locales other
3
+ # than English, add the necessary files in this directory.
4
+ #
5
+ # To use the locales, use `I18n.t`:
6
+ #
7
+ # I18n.t 'hello'
8
+ #
9
+ # In views, this is aliased to just `t`:
10
+ #
11
+ # <%= t('hello') %>
12
+ #
13
+ # To use a different locale, set it with `I18n.locale`:
14
+ #
15
+ # I18n.locale = :es
16
+ #
17
+ # This would use the information in config/locales/es.yml.
18
+ #
19
+ # To learn more, please read the Rails Internationalization guide
20
+ # available at http://guides.rubyonrails.org/i18n.html.
21
+
22
+ en:
23
+ hello: "Hello world"
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+ Rails.application.routes.draw do
3
+ # The priority is based upon order of creation: first created -> highest priority.
4
+ # See how all your routes lay out with "rake routes".
5
+
6
+ # You can have the root of your site routed with "root"
7
+ # root 'welcome#index'
8
+
9
+ # Example of regular route:
10
+ # get 'products/:id' => 'catalog#view'
11
+
12
+ # Example of named route that can be invoked with purchase_url(id: product.id)
13
+ # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
14
+
15
+ # Example resource route (maps HTTP verbs to controller actions automatically):
16
+ # resources :products
17
+
18
+ # Example resource route with options:
19
+ # resources :products do
20
+ # member do
21
+ # get 'short'
22
+ # post 'toggle'
23
+ # end
24
+ #
25
+ # collection do
26
+ # get 'sold'
27
+ # end
28
+ # end
29
+
30
+ # Example resource route with sub-resources:
31
+ # resources :products do
32
+ # resources :comments, :sales
33
+ # resource :seller
34
+ # end
35
+
36
+ # Example resource route with more complex sub-resources:
37
+ # resources :products do
38
+ # resources :comments
39
+ # resources :sales do
40
+ # get 'recent', on: :collection
41
+ # end
42
+ # end
43
+
44
+ # Example resource route with concerns:
45
+ # concern :toggleable do
46
+ # post 'toggle'
47
+ # end
48
+ # resources :posts, concerns: :toggleable
49
+ # resources :photos, concerns: :toggleable
50
+
51
+ # Example resource route within a namespace:
52
+ # namespace :admin do
53
+ # # Directs /admin/products/* to Admin::ProductsController
54
+ # # (app/controllers/admin/products_controller.rb)
55
+ # resources :products
56
+ # end
57
+ end
@@ -0,0 +1,22 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key is used for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+
6
+ # Make sure the secret is at least 30 characters and all random,
7
+ # no regular words or you'll be exposed to dictionary attacks.
8
+ # You can use `rake secret` to generate a secure secret key.
9
+
10
+ # Make sure the secrets in this file are kept private
11
+ # if you're sharing your code publicly.
12
+
13
+ development:
14
+ secret_key_base: 13a9e4a2b56770f61304c9817e7c0c9627967212af1ac8ff4b2780cb825f8f59cecb97c2112f27a68ad67f19acc8de1cb6ed15cb50c60d80c9bb36ca376b5ae7
15
+
16
+ test:
17
+ secret_key_base: 9c48899659bfec764801e2f7552b087bd55ae27ee931a32c300a04b5181c03c96598a395a0503f1b6eb8cce04327394549aa7da8248c6c005d82d147a55a3ca5
18
+
19
+ # Do not keep production secrets in the repository,
20
+ # instead read values from the environment.
21
+ production:
22
+ secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
data/dummy/config.ru ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+ # This file is used by Rack-based servers to start the application.
3
+
4
+ require ::File.expand_path('../config/environment', __FILE__)
5
+ run Rails.application