righter 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +28 -0
- data/app/models/righter_right.rb +75 -0
- data/app/models/righter_rights_righter_role.rb +4 -0
- data/app/models/righter_role.rb +82 -0
- data/app/models/righter_role_grant.rb +7 -0
- data/app/models/righter_roles_user.rb +2 -0
- data/db/migrate/20150910000000_create_righter_rights.rb +21 -0
- data/db/migrate/20150910000001_create_righter_roles.rb +20 -0
- data/db/migrate/20150910000002_righter_roles_righter_access_rights.rb +14 -0
- data/db/migrate/20150910000003_create_righter_roles_users.rb +14 -0
- data/lib/init.rb +1 -0
- data/lib/injections/righter_for_application_controller.rb +31 -0
- data/lib/injections/righter_for_resource.rb +110 -0
- data/lib/injections/righter_for_user.rb +186 -0
- data/lib/righter.rb +9 -0
- data/lib/righter/version.rb +3 -0
- data/lib/righter_error.rb +8 -0
- data/lib/tasks/righter_tasks.rake +4 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +11 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +6 -0
- data/test/dummy/app/controllers/doors_controller.rb +23 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/models/door.rb +10 -0
- data/test/dummy/app/models/house.rb +7 -0
- data/test/dummy/app/models/player.rb +7 -0
- data/test/dummy/app/models/righter_roles_player.rb +2 -0
- data/test/dummy/app/models/user.rb +4 -0
- data/test/dummy/app/views/doors/show.html.erb +1 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +29 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +25 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +41 -0
- data/test/dummy/config/environments/production.rb +79 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/initializers/assets.rb +11 -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/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 +8 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/db/migrate/20150911000000_create_players.rb +18 -0
- data/test/dummy/db/migrate/20150911000002_create_users_table.rb +15 -0
- data/test/dummy/db/migrate/20150911000003_create_doors.rb +14 -0
- data/test/dummy/db/migrate/20150911000004_create_houses.rb +13 -0
- data/test/dummy/db/migrate/20150911000005_add_house_reference_to_doors.rb +9 -0
- data/test/dummy/db/schema.rb +90 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +35 -0
- data/test/dummy/log/test.log +117973 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/0-mgT1BVDUIUlj7bJxvh7Ud3uSbC1DJf0Ok7Ehgieds.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/5Lly_CA8DZvPhQV2jDQx-Y6P_y3Ygra9t5jfSlGhHDA.cache +2 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/9jPCqzZvmeFf31Rz8y3OEo8OQXEHVcwmLgkx0tXs-o8.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/OI6uxGcnsKavdWTtwDAasU3wPx8QXhzBgV0X2n1KjMQ.cache +3 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/VTeG_7OBrkPzWFSh3MrTa0NSl2wOuJfTJ-XP7JqBG2w.cache +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/a2CYO1s9hME5T1pntwZMB7J6dYjS0zCmDxw_7zX1T14.cache +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/d71F8V8hdfF1jAttqkXKdizYR9PcM_zuKn_Lj_73gfE.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/hCBjLjjeqhUCs4tdwCYlGcFA4xohMwurjmZx6OY1a7g.cache +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/hZi1k6tpxxCGYxRe7zY74ItcOI8gZrREOpGuA8JSpGg.cache +3 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/ifgPguUzTOUeqB0zW0GV8DL6HEvPpakIWAzNPVuCGW0.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/j8yaH5wiyIN5a2xePYA_lQm39RgOQh27UiF5A7i6b28.cache +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/o2kqwqoUQ3gkgncZO1IWdVRzFD0wCSQ-HyL62cINFOU.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/pEhaat2KBd5SrT7szC_8R1_6hK17FTpvoRFkmCRSD3M.cache +2 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/pIwp2wi1sfaJlhiwzzvyyV0hKOihhYkP6709hRtpHxg.cache +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/pQIgTfLmEPykNamzxdqBww21SMT7YlZlZGy6hgQ6eVE.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/td9wUl9SLRnSSgE2ZK_VqCzLxTkFiCW50KkOhE916Wo.cache +1 -0
- data/test/factories/doors.rb +10 -0
- data/test/factories/houses.rb +7 -0
- data/test/factories/players.rb +6 -0
- data/test/factories/righter_rights.rb +11 -0
- data/test/factories/righter_roles.rb +9 -0
- data/test/factories/users.rb +9 -0
- data/test/fixtures/players.yml +6 -0
- data/test/fixtures/righter_rights.yml +21 -0
- data/test/fixtures/righter_roles.yml +29 -0
- data/test/fixtures/users.yml +27 -0
- data/test/functional/doors_controller_test.rb +71 -0
- data/test/righter_test.rb +9 -0
- data/test/test_helper.rb +54 -0
- data/test/unit/righter_for_resource_test.rb +137 -0
- data/test/unit/righter_right_test.rb +74 -0
- data/test/unit/righter_role_test.rb +197 -0
- data/test/unit/righter_user_test.rb +271 -0
- metadata +271 -0
@@ -0,0 +1,186 @@
|
|
1
|
+
module RighterForUser
|
2
|
+
include ActionView::Helpers::TextHelper
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
# when includes into an ActiveRecord::Model, creates associations for both model and RighterRole
|
6
|
+
# class RighterRoleModel must exist
|
7
|
+
included do
|
8
|
+
model_sym = model_name.human(count: :many).to_s.underscore.to_sym
|
9
|
+
model_plural_name = ActiveModel::Naming.plural(self)
|
10
|
+
relation = "righter_roles_#{model_plural_name}".to_sym
|
11
|
+
join_class = "RighterRoles#{self}".constantize
|
12
|
+
|
13
|
+
# associate me with RighterRole
|
14
|
+
has_many :righter_roles, -> { uniq }, through: relation
|
15
|
+
has_many relation, dependent: :destroy
|
16
|
+
|
17
|
+
# associate RighterRole with me
|
18
|
+
RighterRole.send :has_many, relation, dependent: :destroy
|
19
|
+
RighterRole.send :has_many, model_sym, through: relation, class_name: to_s
|
20
|
+
RighterRole.send :has_many, model_plural_name.to_sym, through: relation, source: model_sym
|
21
|
+
|
22
|
+
# associate _join_class_
|
23
|
+
# FIXME: check for existing reflections?
|
24
|
+
join_class.send :belongs_to, :righter_role
|
25
|
+
join_class.send :belongs_to, model_name.to_s.underscore.to_sym
|
26
|
+
join_class.send :has_many, model_plural_name.to_sym
|
27
|
+
end
|
28
|
+
|
29
|
+
# @return [Array<RighterRight>}
|
30
|
+
# scope returning associated RighterrRights
|
31
|
+
def righter_rights
|
32
|
+
@@users_id ||= self.class.arel_table[:id]
|
33
|
+
@@right_id ||= RighterRight.arel_table[:id]
|
34
|
+
@@righter_user_class ||= ActiveModel::Naming.singular(self)
|
35
|
+
right_ids = RighterRight.joins(righter_roles: @@righter_user_class).where(@@users_id.eq(id)).select(@@right_id).collect &:id
|
36
|
+
RighterRight.where id: right_ids.uniq
|
37
|
+
end
|
38
|
+
|
39
|
+
def add_role(role)
|
40
|
+
RighterRight.clear_cache
|
41
|
+
if role.class != RighterRole
|
42
|
+
fail RighterError.new("User.add_role accepts only RighterRole instance as input (provided :#{role.class.inspect})")
|
43
|
+
end
|
44
|
+
righter_roles << role
|
45
|
+
save!
|
46
|
+
end
|
47
|
+
|
48
|
+
def remove_role(role)
|
49
|
+
RighterRight.clear_cache
|
50
|
+
if role.class != RighterRole
|
51
|
+
fail RighterError.new("User.add_role accepts only RighterRole instance as input (provided :#{role.class.inspect})")
|
52
|
+
end
|
53
|
+
righter_roles.delete role
|
54
|
+
end
|
55
|
+
|
56
|
+
def righter_accessible?(opts = {})
|
57
|
+
if opts[:resource]
|
58
|
+
righter_accessible_resource? opts
|
59
|
+
|
60
|
+
elsif opts[:role]
|
61
|
+
righter_accessible_role? opts[:role]
|
62
|
+
|
63
|
+
elsif opts[:right]
|
64
|
+
righter_accessible_right? opts[:right]
|
65
|
+
|
66
|
+
elsif opts[:controller] && opts[:action]
|
67
|
+
righter_accessible_ca? opts[:controller], opts[:action]
|
68
|
+
|
69
|
+
else
|
70
|
+
fail RighterError.new("User.righter_accessible? expects as parameter role/right/controller+action. provided: #{opts.inspect}")
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def grantable_roles
|
75
|
+
righter_roles.collect(&:grantable_roles).flatten
|
76
|
+
end
|
77
|
+
|
78
|
+
# should we raise RighterError when user is trying to break the grant rules ?
|
79
|
+
def update_roles_with_respect_to_grants(list_of_roles)
|
80
|
+
user_who_is_updating_roles = User.current_user
|
81
|
+
user_whom_roles_will_be_updated = self
|
82
|
+
|
83
|
+
RighterRight.clear_cache
|
84
|
+
|
85
|
+
User.transaction do
|
86
|
+
remove_all_roles_which_can_be_granted
|
87
|
+
|
88
|
+
grantable_roles = user_who_is_updating_roles.grantable_roles
|
89
|
+
list_of_roles.each do |role|
|
90
|
+
if grantable_roles.include? role
|
91
|
+
user_whom_roles_will_be_updated.add_role role
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def can?(right_name, resource)
|
98
|
+
righter_accessible_resource?(right: right_name, resource: resource)
|
99
|
+
end
|
100
|
+
|
101
|
+
private
|
102
|
+
|
103
|
+
def remove_all_roles_which_can_be_granted
|
104
|
+
user_who_is_updating_roles = User.current_user
|
105
|
+
user_whom_roles_will_be_updated = self
|
106
|
+
|
107
|
+
user_who_is_updating_roles.grantable_roles.each do |grantable_role|
|
108
|
+
if user_whom_roles_will_be_updated.righter_roles.include? grantable_role
|
109
|
+
user_whom_roles_will_be_updated.remove_role grantable_role
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def righter_accessible_resource?(opts)
|
115
|
+
resource = opts[:resource]
|
116
|
+
fail RighterError('cannot check rights for nil resource') unless resource
|
117
|
+
|
118
|
+
unless opts[:right]
|
119
|
+
fail RighterError.new('option :right is missing - which right should be checked on a resource?')
|
120
|
+
end
|
121
|
+
|
122
|
+
unless resource.respond_to?(:righter_right)
|
123
|
+
fail RighterError('cannot check rights for resource which does not respond to righter_right method')
|
124
|
+
end
|
125
|
+
|
126
|
+
right = resource.righter_right(opts[:right], opts)
|
127
|
+
fail RighterError.new("cannot find resource right #{opts[:right].inspect} for resource #{opts[:resource].inspect}") unless right
|
128
|
+
|
129
|
+
_righter_accessible_right?(right)
|
130
|
+
end
|
131
|
+
|
132
|
+
def righter_accessible_role?(role_name)
|
133
|
+
unless [String, Symbol].include?(role_name.class)
|
134
|
+
fail RighterError.new('User.righter_accessible? :role expects role_name as input')
|
135
|
+
end
|
136
|
+
all_user_role_names = righter_roles.collect { |r| r.name.to_sym }
|
137
|
+
all_user_role_names.include? role_name
|
138
|
+
end
|
139
|
+
|
140
|
+
def righter_accessible_right?(right_name)
|
141
|
+
unless [String, Symbol].include?(right_name.class)
|
142
|
+
fail RighterError.new('User.righter_accessible? :right expects right_name as input')
|
143
|
+
end
|
144
|
+
|
145
|
+
r = RighterRight.cached_find_by_name right_name
|
146
|
+
fail RighterError.new("cannot find righter_right with name #{right_name.inspect}") unless r
|
147
|
+
|
148
|
+
_righter_accessible_right?(r)
|
149
|
+
end
|
150
|
+
|
151
|
+
def _righter_accessible_right?(right)
|
152
|
+
fail RighterError.new('no right provided!') unless right
|
153
|
+
|
154
|
+
righter_role_ids = RighterRightsRighterRole.where(righter_right_id: right.id).collect &:righter_role_id
|
155
|
+
user_role_ids = righter_roles.collect &:id
|
156
|
+
|
157
|
+
righter_role_ids.each do |righter_role_id|
|
158
|
+
return true if user_role_ids.include?(righter_role_id)
|
159
|
+
end
|
160
|
+
|
161
|
+
false
|
162
|
+
end
|
163
|
+
|
164
|
+
def righter_accessible_ca?(controller, action)
|
165
|
+
all_user_rights = righter_rights.where(controller: controller.to_s)
|
166
|
+
all_user_rights.each do |user_right|
|
167
|
+
if user_right.controller && user_right.actions
|
168
|
+
if user_right.controller.to_sym == controller
|
169
|
+
right_actions = user_right.actions.collect(&:to_sym)
|
170
|
+
return true if right_actions.include?(action)
|
171
|
+
|
172
|
+
right_actions.each do |right_action| # wildcards
|
173
|
+
return true if right_action.to_s == '*'
|
174
|
+
if right_action.to_s.include?('*')
|
175
|
+
regex = right_action.to_s.gsub('*', '(.*)').gsub('/', '\/')
|
176
|
+
regex_match_result = (action.match /#{regex}/)
|
177
|
+
return true unless regex_match_result.nil?
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
false
|
185
|
+
end
|
186
|
+
end
|
data/lib/righter.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
require "#{File.dirname(__FILE__)}/righter_error.rb"
|
2
|
+
require "#{File.dirname(__FILE__)}/injections/righter_for_application_controller.rb"
|
3
|
+
require "#{File.dirname(__FILE__)}/injections/righter_for_user.rb"
|
4
|
+
require "#{File.dirname(__FILE__)}/injections/righter_for_resource.rb"
|
5
|
+
|
6
|
+
module Righter
|
7
|
+
class Engine < Rails::Engine
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
== README
|
2
|
+
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
|
+
|
6
|
+
Things you may want to cover:
|
7
|
+
|
8
|
+
* Ruby version
|
9
|
+
|
10
|
+
* System dependencies
|
11
|
+
|
12
|
+
* Configuration
|
13
|
+
|
14
|
+
* Database creation
|
15
|
+
|
16
|
+
* Database initialization
|
17
|
+
|
18
|
+
* How to run the test suite
|
19
|
+
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
21
|
+
|
22
|
+
* Deployment instructions
|
23
|
+
|
24
|
+
* ...
|
25
|
+
|
26
|
+
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
28
|
+
<tt>rake doc:app</tt>.
|
data/test/dummy/Rakefile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
3
|
+
|
4
|
+
require File.expand_path('../config/application', __FILE__)
|
5
|
+
|
6
|
+
Rails.application.load_tasks
|
7
|
+
|
8
|
+
Rake::Task['db:migrate'].enhance do
|
9
|
+
ActiveRecord::Migrator.migrate File.expand_path('../../../db/migrate/', __FILE__)
|
10
|
+
Rake::Task['db:schema:dump'].invoke
|
11
|
+
end
|
@@ -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,23 @@
|
|
1
|
+
class DoorsController < ApplicationController
|
2
|
+
def show
|
3
|
+
@door = Door.find(params[:id])
|
4
|
+
end
|
5
|
+
|
6
|
+
def paint
|
7
|
+
@door = Door.find(params[:id])
|
8
|
+
enforce_resource_security(:paint, @door)
|
9
|
+
render :show
|
10
|
+
end
|
11
|
+
|
12
|
+
def change
|
13
|
+
@door = Door.find(params[:id])
|
14
|
+
enforce_resource_security(:change, @door)
|
15
|
+
render :show
|
16
|
+
end
|
17
|
+
|
18
|
+
def open
|
19
|
+
@door = Door.find(params[:id])
|
20
|
+
enforce_resource_security(:open, @door)
|
21
|
+
render :show
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
class Door < ActiveRecord::Base
|
2
|
+
include RighterForResource
|
3
|
+
|
4
|
+
auto_manage_righter_right :paint
|
5
|
+
auto_manage_righter_right :change, auto_associate_roles: [:admin]
|
6
|
+
auto_manage_righter_right :open, auto_associate_roles: [:admin, :user]
|
7
|
+
auto_manage_righter_right :close, parent_right: ->(door) { door.house.righter_right(:build).name }
|
8
|
+
|
9
|
+
belongs_to :house
|
10
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<h1><%= @door.name %></h1>
|
@@ -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/test/dummy/bin/rake
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
# path to your application root.
|
5
|
+
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
6
|
+
|
7
|
+
Dir.chdir APP_ROOT do
|
8
|
+
# This script is a starting point to setup your application.
|
9
|
+
# Add necessary setup steps to this file:
|
10
|
+
|
11
|
+
puts '== Installing dependencies =='
|
12
|
+
system 'gem install bundler --conservative'
|
13
|
+
system 'bundle check || bundle install'
|
14
|
+
|
15
|
+
# puts "\n== Copying sample files =="
|
16
|
+
# unless File.exist?("config/database.yml")
|
17
|
+
# system "cp config/database.yml.sample config/database.yml"
|
18
|
+
# end
|
19
|
+
|
20
|
+
puts "\n== Preparing database =="
|
21
|
+
system 'bin/rake db:setup'
|
22
|
+
|
23
|
+
puts "\n== Removing old logs and tempfiles =="
|
24
|
+
system 'rm -f log/*'
|
25
|
+
system 'rm -rf tmp/cache'
|
26
|
+
|
27
|
+
puts "\n== Restarting application server =="
|
28
|
+
system 'touch tmp/restart.txt'
|
29
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require 'rails/all'
|
4
|
+
|
5
|
+
Bundler.require(*Rails.groups)
|
6
|
+
require 'righter'
|
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
|