careacademy-acl9 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +24 -0
- data/.ruby-version +1 -0
- data/.travis.yml +26 -0
- data/Appraisals +23 -0
- data/CHANGELOG.md +122 -0
- data/CONTRIBUTING.md +62 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +167 -0
- data/LICENSE +9 -0
- data/MIT-LICENSE +20 -0
- data/README.md +326 -0
- data/Rakefile +20 -0
- data/TODO +42 -0
- data/acl9.gemspec +27 -0
- data/bin/appraisal +16 -0
- data/bin/bundler +16 -0
- data/bin/cc-tddium-post-worker +16 -0
- data/bin/erubis +16 -0
- data/bin/rackup +16 -0
- data/bin/rails +16 -0
- data/bin/rake +16 -0
- data/bin/sprockets +16 -0
- data/bin/tapout +16 -0
- data/bin/thor +16 -0
- data/bin/tilt +16 -0
- data/bin/yard +16 -0
- data/bin/yardoc +16 -0
- data/bin/yri +16 -0
- data/gemfiles/.bundle/config +2 -0
- data/gemfiles/rails_5.0.gemfile +10 -0
- data/gemfiles/rails_5.1.gemfile +10 -0
- data/gemfiles/rails_5.2.gemfile +9 -0
- data/gemfiles/rails_6.0.gemfile +9 -0
- data/gemfiles/rails_6.1.gemfile +9 -0
- data/gemfiles/rails_7.0.gemfile +9 -0
- data/lib/acl9/controller_extensions/dsl_base.rb +212 -0
- data/lib/acl9/controller_extensions/generators.rb +166 -0
- data/lib/acl9/controller_extensions.rb +85 -0
- data/lib/acl9/helpers.rb +49 -0
- data/lib/acl9/model_extensions/for_object.rb +74 -0
- data/lib/acl9/model_extensions/for_subject.rb +232 -0
- data/lib/acl9/model_extensions.rb +136 -0
- data/lib/acl9/prepositions.rb +18 -0
- data/lib/acl9/version.rb +3 -0
- data/lib/acl9.rb +78 -0
- data/lib/generators/acl9/setup/USAGE +35 -0
- data/lib/generators/acl9/setup/setup_generator.rb +122 -0
- data/lib/generators/acl9/setup/templates/create_role_tables.rb +31 -0
- data/lib/generators/acl9/setup/templates/role.rb +3 -0
- data/test/config_test.rb +55 -0
- data/test/controller_extensions/actions_test.rb +199 -0
- data/test/controller_extensions/anon_test.rb +39 -0
- data/test/controller_extensions/base.rb +96 -0
- data/test/controller_extensions/basics_test.rb +44 -0
- data/test/controller_extensions/conditions_test.rb +48 -0
- data/test/controller_extensions/method_test.rb +70 -0
- data/test/controller_extensions/multi_match_test.rb +142 -0
- data/test/controller_extensions/multiple_role_arguments_test.rb +136 -0
- data/test/controller_extensions/prepositions_test.rb +108 -0
- data/test/controller_extensions/pseudo_role_test.rb +26 -0
- data/test/controller_extensions/role_test.rb +75 -0
- data/test/controllers/acl_action_override_test.rb +24 -0
- data/test/controllers/acl_arguments_test.rb +5 -0
- data/test/controllers/acl_block_test.rb +5 -0
- data/test/controllers/acl_boolean_method_test.rb +5 -0
- data/test/controllers/acl_helper_method_test.rb +29 -0
- data/test/controllers/acl_ivars_test.rb +15 -0
- data/test/controllers/acl_method2_test.rb +6 -0
- data/test/controllers/acl_method_test.rb +6 -0
- data/test/controllers/acl_object_hash_test.rb +18 -0
- data/test/controllers/acl_query_method_named_test.rb +9 -0
- data/test/controllers/acl_query_method_test.rb +9 -0
- data/test/controllers/acl_query_method_with_lambda_test.rb +9 -0
- data/test/controllers/acl_query_mixin.rb +54 -0
- data/test/controllers/acl_subject_method_test.rb +15 -0
- data/test/controllers/arguments_checking_test.rb +43 -0
- data/test/dummy/app/assets/config/manifest.js +0 -0
- data/test/dummy/app/controllers/acl_action_override.rb +15 -0
- data/test/dummy/app/controllers/acl_arguments.rb +10 -0
- data/test/dummy/app/controllers/acl_block.rb +6 -0
- data/test/dummy/app/controllers/acl_boolean_method.rb +23 -0
- data/test/dummy/app/controllers/acl_helper_method.rb +11 -0
- data/test/dummy/app/controllers/acl_ivars.rb +17 -0
- data/test/dummy/app/controllers/acl_method.rb +6 -0
- data/test/dummy/app/controllers/acl_method2.rb +6 -0
- data/test/dummy/app/controllers/acl_objects_hash.rb +10 -0
- data/test/dummy/app/controllers/acl_query_method.rb +9 -0
- data/test/dummy/app/controllers/acl_query_method_named.rb +15 -0
- data/test/dummy/app/controllers/acl_query_method_with_lambda.rb +9 -0
- data/test/dummy/app/controllers/acl_subject_method.rb +16 -0
- data/test/dummy/app/controllers/application_controller.rb +13 -0
- data/test/dummy/app/controllers/empty_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/helpers/some_helper.rb +8 -0
- data/test/dummy/app/models/.keep +0 -0
- data/test/dummy/app/models/access.rb +3 -0
- data/test/dummy/app/models/account.rb +3 -0
- data/test/dummy/app/models/bar.rb +3 -0
- data/test/dummy/app/models/concerns/.keep +0 -0
- data/test/dummy/app/models/foo.rb +3 -0
- data/test/dummy/app/models/foo_bar.rb +3 -0
- data/test/dummy/app/models/other/foo.rb +5 -0
- data/test/dummy/app/models/other/role.rb +5 -0
- data/test/dummy/app/models/other/user.rb +5 -0
- data/test/dummy/app/models/role.rb +3 -0
- data/test/dummy/app/models/string_object_role.rb +3 -0
- data/test/dummy/app/models/string_user.rb +3 -0
- data/test/dummy/app/models/user.rb +3 -0
- data/test/dummy/app/models/uuid.rb +4 -0
- data/test/dummy/config/application.rb +23 -0
- data/test/dummy/config/boot.rb +4 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/test.rb +40 -0
- data/test/dummy/config/initializers/assets.rb +8 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/secrets.rb +1 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +14 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/migrate/20141117132218_create_tables.rb +149 -0
- data/test/helpers/helper_test.rb +89 -0
- data/test/models/roles_test.rb +369 -0
- data/test/models/roles_with_custom_association_names_test.rb +28 -0
- data/test/models/roles_with_custom_class_names_test.rb +28 -0
- data/test/models/system_roles_test.rb +22 -0
- data/test/models/users_roles_and_subjects_with_namespaced_class_names_test.rb +30 -0
- data/test/test_helper.rb +94 -0
- data/test/version_test.rb +7 -0
- metadata +321 -0
@@ -0,0 +1,9 @@
|
|
1
|
+
class ACLQueryMethod < ApplicationController
|
2
|
+
attr_accessor :current_user
|
3
|
+
|
4
|
+
access_control :acl, :query_method => true do
|
5
|
+
allow :editor, :to => [:edit, :update, :destroy]
|
6
|
+
allow :viewer, :to => [:index, :show]
|
7
|
+
allow :owner, :of => :foo, :to => :fooize
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class ACLQueryMethodNamed < ApplicationController
|
2
|
+
attr_accessor :current_user
|
3
|
+
|
4
|
+
access_control :acl, :query_method => 'allow_ay' do
|
5
|
+
allow :editor, :to => [:edit, :update, :destroy]
|
6
|
+
allow :viewer, :to => [:index, :show]
|
7
|
+
allow :owner, :of => :foo, :to => :fooize
|
8
|
+
end
|
9
|
+
|
10
|
+
def acl?(*args)
|
11
|
+
@foo = Foo.first
|
12
|
+
|
13
|
+
allow_ay(*args)
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
class ACLQueryMethodWithLambda < ApplicationController
|
2
|
+
attr_accessor :current_user
|
3
|
+
|
4
|
+
access_control :query_method => :acl? do
|
5
|
+
allow :editor, :to => [:edit, :update, :destroy]
|
6
|
+
allow :viewer, :to => [:index, :show]
|
7
|
+
allow :owner, :of => :foo, :to => :fooize
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class ACLSubjectMethod < ApplicationController
|
2
|
+
access_control :subject_method => :the_only_user do
|
3
|
+
allow :the_only_one
|
4
|
+
end
|
5
|
+
|
6
|
+
def index
|
7
|
+
head :ok
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
alias_method :the_only_user, :current_user
|
13
|
+
def current_user
|
14
|
+
raise "ACK!"
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class ApplicationController < ActionController::Base
|
2
|
+
before_action :before_action
|
3
|
+
|
4
|
+
attr_accessor :current_user
|
5
|
+
|
6
|
+
def current_user
|
7
|
+
@current_user ||= User.find params[:user_id] if params[:user_id]
|
8
|
+
end
|
9
|
+
|
10
|
+
def before_action
|
11
|
+
@foo = Foo.first
|
12
|
+
end
|
13
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require 'rails/all'
|
4
|
+
|
5
|
+
# Require the gems listed in Gemfile, including any gems
|
6
|
+
# you've limited to :test, :development, or :production.
|
7
|
+
Bundler.require
|
8
|
+
|
9
|
+
module Dummy
|
10
|
+
class Application < Rails::Application
|
11
|
+
# Settings in config/environments/* take precedence over those specified here.
|
12
|
+
# Application configuration should go into files in config/initializers
|
13
|
+
# -- all .rb files in that directory are automatically loaded.
|
14
|
+
|
15
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
16
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
17
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
18
|
+
|
19
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
20
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
21
|
+
# config.i18n.default_locale = :de
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# SQLite version 3.x
|
2
|
+
# gem install sqlite3
|
3
|
+
#
|
4
|
+
# Ensure the SQLite 3 gem is defined in your Gemfile
|
5
|
+
# gem 'sqlite3'
|
6
|
+
#
|
7
|
+
default: &default
|
8
|
+
adapter: sqlite3
|
9
|
+
pool: 5
|
10
|
+
timeout: 5000
|
11
|
+
|
12
|
+
development:
|
13
|
+
<<: *default
|
14
|
+
database: ':memory:'
|
15
|
+
|
16
|
+
# Warning: The database defined as "test" will be erased and
|
17
|
+
# re-generated from your development database when you run "rake".
|
18
|
+
# Do not set this db to the same as development or production.
|
19
|
+
test:
|
20
|
+
<<: *default
|
21
|
+
database: ':memory:'
|
22
|
+
|
23
|
+
production:
|
24
|
+
<<: *default
|
25
|
+
database: ':memory:'
|
@@ -0,0 +1,37 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
|
+
|
4
|
+
# In the development environment your application's code is reloaded on
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the web server when you make code changes.
|
7
|
+
config.cache_classes = false
|
8
|
+
|
9
|
+
# Do not eager load code on boot.
|
10
|
+
config.eager_load = false
|
11
|
+
|
12
|
+
# Show full error reports and disable caching.
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
config.action_controller.perform_caching = false
|
15
|
+
|
16
|
+
# Don't care if the mailer can't send.
|
17
|
+
config.action_mailer.raise_delivery_errors = false
|
18
|
+
|
19
|
+
# Print deprecation notices to the Rails logger.
|
20
|
+
config.active_support.deprecation = :log
|
21
|
+
|
22
|
+
# Raise an error on page load if there are pending migrations.
|
23
|
+
config.active_record.migration_error = :page_load
|
24
|
+
|
25
|
+
# Debug mode disables concatenation and preprocessing of assets.
|
26
|
+
# This option may cause significant delays in view rendering with a large
|
27
|
+
# number of complex assets.
|
28
|
+
config.assets.debug = true
|
29
|
+
|
30
|
+
# Adds additional error checking when serving assets at runtime.
|
31
|
+
# Checks for improperly declared sprockets dependencies.
|
32
|
+
# Raises helpful error messages.
|
33
|
+
config.assets.raise_runtime_errors = true
|
34
|
+
|
35
|
+
# Raises error for missing translations
|
36
|
+
# config.action_view.raise_on_missing_translations = true
|
37
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
|
+
|
4
|
+
# The test environment is used exclusively to run your application's
|
5
|
+
# test suite. You never need to work with it otherwise. Remember that
|
6
|
+
# your test database is "scratch space" for the test suite and is wiped
|
7
|
+
# and recreated between test runs. Don't rely on the data there!
|
8
|
+
config.cache_classes = true
|
9
|
+
|
10
|
+
# Do not eager load code on boot. This avoids loading your whole application
|
11
|
+
# just for the purpose of running a single test. If you are using a tool that
|
12
|
+
# preloads Rails for running tests, you may have to set it to true.
|
13
|
+
config.eager_load = false
|
14
|
+
|
15
|
+
# Configure static asset server for tests with Cache-Control for performance.
|
16
|
+
config.public_file_server.enabled = true
|
17
|
+
config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' }
|
18
|
+
|
19
|
+
# Show full error reports and disable caching.
|
20
|
+
config.consider_all_requests_local = true
|
21
|
+
config.action_controller.perform_caching = false
|
22
|
+
|
23
|
+
# Raise exceptions instead of rendering exception templates.
|
24
|
+
config.action_dispatch.show_exceptions = false
|
25
|
+
|
26
|
+
# Disable request forgery protection in test environment.
|
27
|
+
config.action_controller.allow_forgery_protection = false
|
28
|
+
|
29
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
30
|
+
# The :test delivery method accumulates sent emails in the
|
31
|
+
# ActionMailer::Base.deliveries array.
|
32
|
+
config.action_mailer.delivery_method = :test
|
33
|
+
|
34
|
+
# Print deprecation notices to the stderr.
|
35
|
+
config.active_support.deprecation = :stderr
|
36
|
+
|
37
|
+
# Raises error for missing translations
|
38
|
+
# config.action_view.raise_on_missing_translations = true
|
39
|
+
config.log_level = :unknown
|
40
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Version of your assets, change this if you want to expire all your assets.
|
4
|
+
Dummy::Application.config.assets.version = '1.0'
|
5
|
+
|
6
|
+
# Precompile additional assets.
|
7
|
+
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
8
|
+
# Rails.application.config.assets.precompile += %w( search.js )
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
4
|
+
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
5
|
+
|
6
|
+
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
7
|
+
# Rails.backtrace_cleaner.remove_silencers!
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Add new inflection rules using the following format. Inflections
|
4
|
+
# are locale specific, and you may define rules for as many different
|
5
|
+
# locales as you wish. All of these examples are active by default:
|
6
|
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
7
|
+
# inflect.plural /^(ox)$/i, '\1en'
|
8
|
+
# inflect.singular /^(ox)en/i, '\1'
|
9
|
+
# inflect.irregular 'person', 'people'
|
10
|
+
# inflect.uncountable %w( fish sheep )
|
11
|
+
# end
|
12
|
+
|
13
|
+
# These inflection rules are supported but not enabled by default:
|
14
|
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
15
|
+
# inflect.acronym 'RESTful'
|
16
|
+
# end
|
@@ -0,0 +1 @@
|
|
1
|
+
Dummy::Application.config.secret_key_base = 'b29f2acba41e296f52ae4e3d11de570df29f69fe1ca9cad18634fec6fc2569d0b32ce5f66a822758a80bf6c9c828b038e0366f098397df636479b4ec437c9a46'
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# This file contains settings for ActionController::ParamsWrapper which
|
4
|
+
# is enabled by default.
|
5
|
+
|
6
|
+
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
7
|
+
ActiveSupport.on_load(:action_controller) do
|
8
|
+
wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
|
9
|
+
end
|
10
|
+
|
11
|
+
# To enable root element in JSON for ActiveRecord objects.
|
12
|
+
# ActiveSupport.on_load(:active_record) do
|
13
|
+
# self.include_root_in_json = true
|
14
|
+
# 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,14 @@
|
|
1
|
+
Dummy::Application.routes.draw do
|
2
|
+
resources :acl_action_override do
|
3
|
+
collection do
|
4
|
+
get :check_allow_with_foo
|
5
|
+
get :check_allow
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
resources :acl_boolean_method, :acl_block, :acl_ivars, :acl_method, :acl_method2, :acl_subject_method, :acl_arguments
|
10
|
+
|
11
|
+
get :acl_helper_method, to: "acl_helper_method#allow"
|
12
|
+
get :acl_objects_hash, to: "acl_objects_hash#allow"
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,149 @@
|
|
1
|
+
class CreateTables < ActiveRecord::Migration[ActiveRecord::Migration.current_version]
|
2
|
+
def self.r5?
|
3
|
+
Rails.gem_version >= Gem::Version.new(5)
|
4
|
+
end
|
5
|
+
def r5?
|
6
|
+
self.class.r5?
|
7
|
+
end
|
8
|
+
|
9
|
+
def change
|
10
|
+
create_table :roles do |t|
|
11
|
+
t.string :name, :limit => 40
|
12
|
+
t.boolean :system
|
13
|
+
if r5?
|
14
|
+
t.references :authorizable, polymorphic: true
|
15
|
+
else
|
16
|
+
t.string :authorizable_type, :limit => 40
|
17
|
+
t.integer :authorizable_id
|
18
|
+
end
|
19
|
+
t.timestamps null: false
|
20
|
+
end
|
21
|
+
|
22
|
+
unless r5?
|
23
|
+
add_index :roles, [:authorizable_type, :authorizable_id]
|
24
|
+
end
|
25
|
+
|
26
|
+
create_table :roles_users, id: false do |t|
|
27
|
+
t.references :user
|
28
|
+
t.references :role
|
29
|
+
end
|
30
|
+
|
31
|
+
unless r5?
|
32
|
+
add_index :roles_users, :user_id
|
33
|
+
add_index :roles_users, :role_id
|
34
|
+
end
|
35
|
+
|
36
|
+
create_table :users do |t|
|
37
|
+
t.string :name
|
38
|
+
t.timestamps null: false
|
39
|
+
end
|
40
|
+
|
41
|
+
create_table :foos do |t|
|
42
|
+
t.string :name
|
43
|
+
t.timestamps null: false
|
44
|
+
end
|
45
|
+
|
46
|
+
create_table :bars do |t|
|
47
|
+
t.string :name
|
48
|
+
t.timestamps null: false
|
49
|
+
end
|
50
|
+
|
51
|
+
create_table :uuids, id: false do |t|
|
52
|
+
t.string :uuid, primary_key: true
|
53
|
+
t.string :name
|
54
|
+
t.timestamps null: false
|
55
|
+
end
|
56
|
+
|
57
|
+
create_table :string_object_roles do |t|
|
58
|
+
t.string :name
|
59
|
+
t.boolean :system
|
60
|
+
t.string :authorizable_type
|
61
|
+
t.string :authorizable_id
|
62
|
+
t.timestamps null: false
|
63
|
+
end
|
64
|
+
|
65
|
+
create_table :string_object_roles_string_users, id: false do |t|
|
66
|
+
t.references :string_user, index: { name: "susor" }
|
67
|
+
t.references :string_object_role, index: { name: "sorsu" }
|
68
|
+
end
|
69
|
+
|
70
|
+
create_table :string_users do |t|
|
71
|
+
t.string :name
|
72
|
+
t.timestamps null: false
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
create_table :accounts do |t|
|
77
|
+
t.string :name
|
78
|
+
t.timestamps null: false
|
79
|
+
end
|
80
|
+
|
81
|
+
create_table :accesses do |t|
|
82
|
+
t.string :name
|
83
|
+
t.boolean :system
|
84
|
+
if r5?
|
85
|
+
t.references :authorizable, polymorphic: true
|
86
|
+
else
|
87
|
+
t.string :authorizable_type, :limit => 40
|
88
|
+
t.integer :authorizable_id
|
89
|
+
end
|
90
|
+
t.timestamps null: false
|
91
|
+
end
|
92
|
+
|
93
|
+
unless r5?
|
94
|
+
add_index :accesses, [:authorizable_type, :authorizable_id]
|
95
|
+
end
|
96
|
+
|
97
|
+
create_table :accesses_accounts, id: false do |t|
|
98
|
+
t.references :account
|
99
|
+
t.references :access
|
100
|
+
end
|
101
|
+
|
102
|
+
unless r5?
|
103
|
+
add_index :accesses_accounts, :access_id
|
104
|
+
add_index :accesses_accounts, :account_id
|
105
|
+
end
|
106
|
+
|
107
|
+
create_table :foo_bars do |t|
|
108
|
+
t.string :name
|
109
|
+
t.timestamps null: false
|
110
|
+
end
|
111
|
+
|
112
|
+
|
113
|
+
create_table :other_roles do |t|
|
114
|
+
t.string :name, :limit => 40
|
115
|
+
t.boolean :system
|
116
|
+
if r5?
|
117
|
+
t.references :authorizable, polymorphic: true
|
118
|
+
else
|
119
|
+
t.string :authorizable_type, :limit => 40
|
120
|
+
t.integer :authorizable_id
|
121
|
+
end
|
122
|
+
t.timestamps null: false
|
123
|
+
end
|
124
|
+
|
125
|
+
unless r5?
|
126
|
+
add_index :other_roles, [:authorizable_type, :authorizable_id]
|
127
|
+
end
|
128
|
+
|
129
|
+
create_table :other_roles_users, id: false do |t|
|
130
|
+
t.references :user
|
131
|
+
t.references :role
|
132
|
+
end
|
133
|
+
|
134
|
+
unless r5?
|
135
|
+
add_index :other_roles_users, :user_id
|
136
|
+
add_index :other_roles_users, :role_id
|
137
|
+
end
|
138
|
+
|
139
|
+
create_table :other_users do |t|
|
140
|
+
t.string :name
|
141
|
+
t.timestamps null: false
|
142
|
+
end
|
143
|
+
|
144
|
+
create_table :other_foos do |t|
|
145
|
+
t.string :name
|
146
|
+
t.timestamps null: false
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|