the_role 2.5.4 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +178 -526
  3. data/gem_version.rb +3 -0
  4. data/lib/the_role/version.rb +1 -3
  5. data/lib/the_role.rb +3 -41
  6. data/the_role.gemspec +5 -5
  7. metadata +20 -231
  8. data/.ruby-gemset.example +0 -1
  9. data/.ruby-version.example +0 -1
  10. data/.rvmrc.example +0 -1
  11. data/.travis.yml +0 -5
  12. data/Bye_bye_CanCan_I_got_the_Role.png +0 -0
  13. data/app/controllers/admin/role_sections_controller.rb +0 -90
  14. data/app/controllers/admin/roles_controller.rb +0 -74
  15. data/app/controllers/concerns/controller.rb +0 -23
  16. data/app/models/_templates_/role.rb +0 -3
  17. data/app/models/concerns/base.rb +0 -37
  18. data/app/models/concerns/role.rb +0 -156
  19. data/app/models/concerns/user.rb +0 -57
  20. data/config/locales/en.yml +0 -44
  21. data/config/locales/es.yml +0 -42
  22. data/config/locales/nl.yml +0 -44
  23. data/config/locales/pl.yml +0 -43
  24. data/config/locales/pt_BR.yml +0 -43
  25. data/config/locales/ru.yml +0 -43
  26. data/config/locales/zh_CN.yml +0 -42
  27. data/config/routes.rb +0 -23
  28. data/db/migrate/20111025025129_create_roles.rb +0 -23
  29. data/docs/2.1.1.png +0 -0
  30. data/lib/generators/the_role/USAGE +0 -32
  31. data/lib/generators/the_role/templates/the_role.rb +0 -11
  32. data/lib/generators/the_role/the_role_generator.rb +0 -64
  33. data/lib/tasks/roles.rake +0 -137
  34. data/lib/the_role/activerecord.rb +0 -11
  35. data/lib/the_role/config.rb +0 -30
  36. data/lib/the_role/hash.rb +0 -58
  37. data/lib/the_role/the_class_exists.rb +0 -8
  38. data/pic.png +0 -0
  39. data/spec/dummy_app/.gitignore +0 -18
  40. data/spec/dummy_app/.rspec +0 -1
  41. data/spec/dummy_app/Gemfile +0 -43
  42. data/spec/dummy_app/README.md +0 -39
  43. data/spec/dummy_app/Rakefile +0 -6
  44. data/spec/dummy_app/app/assets/images/.keep +0 -0
  45. data/spec/dummy_app/app/assets/javascripts/application.js +0 -17
  46. data/spec/dummy_app/app/assets/stylesheets/app/style.css.scss +0 -23
  47. data/spec/dummy_app/app/assets/stylesheets/application.css +0 -3
  48. data/spec/dummy_app/app/controllers/application_controller.rb +0 -38
  49. data/spec/dummy_app/app/controllers/concerns/.keep +0 -0
  50. data/spec/dummy_app/app/controllers/pages_controller.rb +0 -75
  51. data/spec/dummy_app/app/controllers/users_controller.rb +0 -32
  52. data/spec/dummy_app/app/controllers/welcome_controller.rb +0 -13
  53. data/spec/dummy_app/app/helpers/application_helper.rb +0 -2
  54. data/spec/dummy_app/app/mailers/.keep +0 -0
  55. data/spec/dummy_app/app/models/.keep +0 -0
  56. data/spec/dummy_app/app/models/concerns/.keep +0 -0
  57. data/spec/dummy_app/app/models/page.rb +0 -24
  58. data/spec/dummy_app/app/models/role.rb +0 -4
  59. data/spec/dummy_app/app/models/user.rb +0 -21
  60. data/spec/dummy_app/app/views/layouts/_current_user_info.html.haml +0 -17
  61. data/spec/dummy_app/app/views/layouts/application.html.haml +0 -68
  62. data/spec/dummy_app/app/views/pages/_form.html.haml +0 -19
  63. data/spec/dummy_app/app/views/pages/edit.html.haml +0 -7
  64. data/spec/dummy_app/app/views/pages/index.html.haml +0 -27
  65. data/spec/dummy_app/app/views/pages/manage.html.haml +0 -23
  66. data/spec/dummy_app/app/views/pages/my.html.haml +0 -10
  67. data/spec/dummy_app/app/views/pages/new.html.haml +0 -5
  68. data/spec/dummy_app/app/views/pages/show.html.haml +0 -15
  69. data/spec/dummy_app/app/views/users/edit.html.haml +0 -34
  70. data/spec/dummy_app/app/views/welcome/index.html.haml +0 -38
  71. data/spec/dummy_app/app/views/welcome/profile.html.haml +0 -2
  72. data/spec/dummy_app/bin/bundle +0 -3
  73. data/spec/dummy_app/bin/rails +0 -4
  74. data/spec/dummy_app/bin/rake +0 -4
  75. data/spec/dummy_app/config/application.rb +0 -25
  76. data/spec/dummy_app/config/boot.rb +0 -4
  77. data/spec/dummy_app/config/database.yml +0 -17
  78. data/spec/dummy_app/config/environment.rb +0 -5
  79. data/spec/dummy_app/config/environments/development.rb +0 -29
  80. data/spec/dummy_app/config/environments/production.rb +0 -80
  81. data/spec/dummy_app/config/environments/test.rb +0 -36
  82. data/spec/dummy_app/config/initializers/backtrace_silencers.rb +0 -7
  83. data/spec/dummy_app/config/initializers/devise.rb +0 -227
  84. data/spec/dummy_app/config/initializers/filter_parameter_logging.rb +0 -4
  85. data/spec/dummy_app/config/initializers/inflections.rb +0 -16
  86. data/spec/dummy_app/config/initializers/mime_types.rb +0 -5
  87. data/spec/dummy_app/config/initializers/secret_token.rb +0 -12
  88. data/spec/dummy_app/config/initializers/session_store.rb +0 -3
  89. data/spec/dummy_app/config/initializers/the_role.rb +0 -6
  90. data/spec/dummy_app/config/initializers/wrap_parameters.rb +0 -14
  91. data/spec/dummy_app/config/locales/devise.en.yml +0 -57
  92. data/spec/dummy_app/config/locales/en.yml +0 -7
  93. data/spec/dummy_app/config/locales/ru.yml +0 -4
  94. data/spec/dummy_app/config/routes.rb +0 -26
  95. data/spec/dummy_app/config.ru +0 -4
  96. data/spec/dummy_app/db/migrate/20120212061952_devise_create_users.rb +0 -63
  97. data/spec/dummy_app/db/migrate/20120212063249_create_roles.rb +0 -18
  98. data/spec/dummy_app/db/migrate/20120314061307_create_pages.rb +0 -14
  99. data/spec/dummy_app/db/schema.rb +0 -59
  100. data/spec/dummy_app/db/seeds.rb +0 -85
  101. data/spec/dummy_app/lib/assets/.keep +0 -0
  102. data/spec/dummy_app/lib/tasks/.keep +0 -0
  103. data/spec/dummy_app/lib/tasks/assets.rake +0 -15
  104. data/spec/dummy_app/lib/tasks/db_bootstrap.rake +0 -16
  105. data/spec/dummy_app/log/.keep +0 -0
  106. data/spec/dummy_app/public/404.html +0 -58
  107. data/spec/dummy_app/public/422.html +0 -58
  108. data/spec/dummy_app/public/500.html +0 -57
  109. data/spec/dummy_app/public/favicon.ico +0 -0
  110. data/spec/dummy_app/public/robots.txt +0 -5
  111. data/spec/dummy_app/spec/controllers/admin_roles_controller_spec.rb +0 -52
  112. data/spec/dummy_app/spec/controllers/pages_controller_spec.rb +0 -141
  113. data/spec/dummy_app/spec/controllers/welcome_controller_spec.rb +0 -66
  114. data/spec/dummy_app/spec/factories/page.rb +0 -6
  115. data/spec/dummy_app/spec/factories/role.rb +0 -55
  116. data/spec/dummy_app/spec/factories/user.rb +0 -11
  117. data/spec/dummy_app/spec/models/hash_spec.rb +0 -272
  118. data/spec/dummy_app/spec/models/param_process_spec.rb +0 -39
  119. data/spec/dummy_app/spec/models/role_spec.rb +0 -218
  120. data/spec/dummy_app/spec/models/user_spec.rb +0 -164
  121. data/spec/dummy_app/spec/routing/admin_roles_routing_spec.rb +0 -41
  122. data/spec/dummy_app/spec/routing/pages_routing_spec.rb +0 -35
  123. data/spec/dummy_app/spec/spec_helper.rb +0 -68
  124. data/spec/dummy_app/vendor/assets/javascripts/.keep +0 -0
  125. data/spec/dummy_app/vendor/assets/stylesheets/.keep +0 -0
  126. data/the_role.yml.teamocil.example +0 -11
data/lib/tasks/roles.rake DELETED
@@ -1,137 +0,0 @@
1
- namespace :db do
2
- namespace :roles do
3
- # rake db:roles:admin
4
- desc 'create Admin Role'
5
- task :admin => :environment do
6
- puts `clear`
7
- puts '~'*40
8
- puts 'TheRole'
9
- puts '~'*40
10
-
11
- TheRole.create_admin!
12
-
13
- puts "Now you can makes any user as Admin:"
14
- puts "> rails c"
15
- puts "> User.first.update( role: Role.with_name(:admin) )"
16
- puts '~'*40
17
- end
18
-
19
- # rake db:roles:test
20
- desc 'create roles'
21
- task :test => :environment do
22
- # ADMIN
23
- Rake::Task["db:roles:admin"].invoke
24
- puts 'Administrator'
25
-
26
- # MODERATOR
27
- role = {
28
- :users => {
29
- :edit => true,
30
- :show => true,
31
- :update => true
32
- },
33
- :moderator => {
34
- :pages => true
35
- },
36
- :markup => {
37
- :html => true
38
- }
39
- }
40
-
41
- Role.create!(
42
- :name => :moderator,
43
- :title => 'Moderator of pages',
44
- :description => "Moderator #1",
45
- :the_role => role.to_json
46
- )
47
-
48
- puts 'Moderator of pages'
49
-
50
- # USER
51
- role = {
52
- :users => {
53
- :edit => true,
54
- :show => true,
55
- :update => true
56
- },
57
- :profiles => {
58
- :edit => true,
59
- :update => true
60
- },
61
- :articles => {
62
- :new => true,
63
- :create => true,
64
- :edit => true,
65
- :update => true,
66
- :destroy => true,
67
- :tags => false
68
- },
69
- :pages => {
70
- :new => true,
71
- :create => true,
72
- :edit => true,
73
- :update => true,
74
- :destroy => true,
75
- :tags => true
76
- },
77
- :markup => {
78
- :html => false
79
- }
80
- }
81
-
82
- Role.create!(
83
- :name => :user,
84
- :title => 'User',
85
- :description => "Role for User",
86
- :the_role => role.to_json
87
- )
88
-
89
- puts 'User'
90
-
91
- # DEMO
92
- role = {
93
- :users => {
94
- :edit => true,
95
- :show => true,
96
- :update => true
97
- },
98
- :profiles => {
99
- :edit => true,
100
- :update => false
101
- },
102
- :articles => {
103
- :new => true,
104
- :show => true,
105
- :create => false,
106
- :edit => true,
107
- :update => false,
108
- :destroy => false,
109
- :tags => false
110
- },
111
- :pages => {
112
- :new => true,
113
- :show => true,
114
- :create => false,
115
- :edit => true,
116
- :update => false,
117
- :destroy => false,
118
- :tags => false
119
- },
120
- :markup => {
121
- :html => false
122
- }
123
- }
124
-
125
- Role.create!(
126
- :name => :demo,
127
- :title => 'Demo',
128
- :description => "Demo user",
129
- :the_role => role.to_json
130
- )
131
-
132
- puts 'Demo'
133
-
134
- puts 'Roles created'
135
- end
136
- end
137
- end
@@ -1,11 +0,0 @@
1
- module TheRole
2
- module ActiveRecord
3
- def has_role
4
- include TheRole::User
5
- end
6
-
7
- def acts_as_role
8
- include TheRole::Role
9
- end
10
- end
11
- end
@@ -1,30 +0,0 @@
1
- module TheRole
2
- def self.configure(&block)
3
- yield @config ||= TheRole::Configuration.new
4
- end
5
-
6
- def self.config
7
- @config
8
- end
9
-
10
- # Configuration class
11
- class Configuration
12
- include ActiveSupport::Configurable
13
- config_accessor :layout,
14
- :destroy_strategy,
15
- :default_user_role,
16
- :access_denied_method,
17
- :login_required_method,
18
- :first_user_should_be_admin
19
- end
20
-
21
- configure do |config|
22
- config.layout = :application
23
-
24
- config.default_user_role = nil
25
- config.first_user_should_be_admin = false
26
- config.access_denied_method = :access_denied
27
- config.login_required_method = :authenticate_user!
28
- config.destroy_strategy = :restrict_with_exception # can be nil
29
- end
30
- end
data/lib/the_role/hash.rb DELETED
@@ -1,58 +0,0 @@
1
- # load 'the_role/hash.rb' - UPDATE, BUT NOT RELOAD [for console testing]
2
- class Hash
3
- # deep_transform_keys
4
- # deep_stringify_keys
5
- # underscorify_keys
6
- # deep_reset
7
- unless {}.respond_to?(:deep_transform_keys)
8
- def deep_transform_keys(&block)
9
- result = {}
10
- each do |key, value|
11
- result[yield(key)] = value.is_a?(Hash) ? value.deep_transform_keys(&block) : value
12
- end
13
- result
14
- end
15
-
16
- def deep_transform_keys!(&block)
17
- keys.each do |key|
18
- value = delete(key)
19
- self[yield(key)] = value.is_a?(Hash) ? value.deep_transform_keys!(&block) : value
20
- end
21
- self
22
- end
23
- end
24
-
25
- unless {}.respond_to?(:deep_stringify_keys)
26
- def deep_stringify_keys
27
- deep_transform_keys{ |key| key.to_s }
28
- end
29
-
30
- def deep_stringify_keys!
31
- deep_transform_keys!{ |key| key.to_s }
32
- end
33
- end
34
-
35
- unless {}.respond_to?(:underscorify_keys)
36
- def underscorify_keys
37
- deep_transform_keys{ |key| key.to_slug_param(sep: '_') }
38
- end
39
-
40
- def underscorify_keys!
41
- replace underscorify_keys
42
- end
43
- end
44
-
45
- unless {}.respond_to?(:deep_reset)
46
- def deep_reset(default = nil)
47
- hash = dup
48
- hash.each do |key, value|
49
- hash[key] = hash[key].is_a?(Hash) ? hash[key].deep_reset(default) : default
50
- end
51
- hash
52
- end
53
-
54
- def deep_reset!(default = nil)
55
- replace deep_reset(default)
56
- end
57
- end
58
- end
@@ -1,8 +0,0 @@
1
- # the_class_exists? :User => true | flase
2
- # the_class_exists? :Role => true | flase
3
- def the_class_exists?(class_name)
4
- klass = Module.const_get(class_name)
5
- return klass.is_a?(Class)
6
- rescue NameError
7
- return false
8
- end
data/pic.png DELETED
Binary file
@@ -1,18 +0,0 @@
1
- # See http://help.github.com/ignore-files/ for more about ignoring files.
2
- #
3
- # If you find yourself ignoring temporary files generated by your text editor
4
- # or operating system, you probably want to add a global ignore instead:
5
- # git config --global core.excludesfile '~/.gitignore_global'
6
-
7
- # Ignore bundler config.
8
- /.bundle
9
-
10
- # Ignore the default SQLite database.
11
- /db/*.db
12
- /db/*.sqlite3
13
- /db/*.sqlite3-journal
14
-
15
- # Ignore all logfiles and tempfiles.
16
- .rvmrc
17
- /log/*.log
18
- /tmp
@@ -1 +0,0 @@
1
- --color
@@ -1,43 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'rails'
4
-
5
- gem 'devise'
6
- gem 'sqlite3'
7
- gem 'state_machine', '~> 1.2.0'
8
-
9
- gem 'sprockets-rails', github: 'rails/sprockets-rails'
10
- gem 'coffee-rails', github: 'rails/coffee-rails'
11
- gem 'sass-rails', github: 'rails/sass-rails'
12
-
13
- gem 'bootstrap-sass', github: 'thomas-mcdonald/bootstrap-sass'
14
-
15
- gem 'faker'
16
- gem 'uglifier'
17
-
18
- gem 'jquery-rails'
19
- gem 'jbuilder', '~> 1.0.1'
20
-
21
- # gem 'the_string_to_slug', path: "../../../the_string_to_slug"
22
-
23
- gem 'the_role',
24
- path: '../../'
25
- # "~> 2.5.3"
26
-
27
- gem 'the_role_bootstrap3_ui',
28
- # path: "path: '../../../../../the_role_bootstrap3_ui"
29
- github: 'the-teacher/the_role_bootstrap3_ui',
30
- branch: 'master'
31
-
32
- group :development do
33
- gem 'pry-rails'
34
- end
35
-
36
- group :test do
37
- gem 'factory_girl_rails', '~> 4.0'
38
- gem 'database_cleaner', git: 'https://github.com/bmabey/database_cleaner.git', tag: 'v1.0.0'
39
-
40
- gem 'rspec', '2.14.1'
41
- gem 'rspec-core', '2.14.4'
42
- gem 'rspec-rails', '2.14.0'
43
- end
@@ -1,39 +0,0 @@
1
- ## TheRole test App
2
-
3
- App for development and testing TheRole gem
4
-
5
- ### How to get?
6
-
7
- ```
8
- git clone git@github.com:the-teacher/the_role.git
9
-
10
- cd the_role/spec/dummy_app/
11
-
12
- bundle
13
- ```
14
-
15
- ### Start it!
16
-
17
- ```
18
- rake db:bootstrap_and_seed
19
-
20
- rails s
21
- ```
22
-
23
- ### Test it!
24
-
25
- ```
26
- rake db:bootstrap RAILS_ENV=test
27
- rspec --format documentation
28
-
29
- rspec spec/models/ --format documentation
30
- ```
31
-
32
- ### Production mode
33
-
34
- ```
35
- rake assets:build RAILS_ENV=production
36
- rake db:test_launch RAILS_ENV=production
37
-
38
- rails s -e production
39
- ```
@@ -1,6 +0,0 @@
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
File without changes
@@ -1,17 +0,0 @@
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 vendor/assets/javascripts of plugins, if any, 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
- // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
- // GO AFTER THE REQUIRES BELOW.
12
- //
13
- //= require jquery
14
- //= require jquery_ujs
15
-
16
- //= require bootstrap
17
- //= require the_role_editinplace
@@ -1,23 +0,0 @@
1
- .header{
2
- margin: 10px 0;
3
- background-color: #DCEAF4;
4
- padding: 5px 10px 10px 10px;
5
- border-radius: 5px;
6
- }
7
-
8
- .manage_panel, .main_content{
9
- background-color: #DCEAF4;
10
- padding: 5px 10px 10px 10px;
11
- border-radius: 5px;
12
- }
13
-
14
- .main_content{
15
- h1{
16
- padding-bottom: 10px;
17
- border-bottom: 1px solid gray;
18
- }
19
- }
20
-
21
- .edit_role{
22
- input{ margin: 0; }
23
- }
@@ -1,3 +0,0 @@
1
- /*
2
- //= require bootstrap
3
- */
@@ -1,38 +0,0 @@
1
- class ApplicationController < ActionController::Base
2
- include TheRole::Controller
3
-
4
- # Prevent CSRF attacks by raising an exception.
5
- # For APIs, you may want to use :null_session instead.
6
- protect_from_forgery with: :exception
7
-
8
- protect_from_forgery
9
- before_filter :set_locale
10
-
11
- def access_denied
12
- flash[:error] = t('the_role.access_denied')
13
- redirect_to(:back)
14
- end
15
-
16
- private
17
-
18
- def set_locale
19
- locale = 'en'
20
- langs = %w{ en ru es pl zh_CN }
21
-
22
- if params[:locale]
23
- lang = params[:locale]
24
- if langs.include? lang
25
- locale = lang
26
- cookies[:locale] = lang
27
- end
28
- else
29
- if cookies[:locale]
30
- lang = cookies[:locale]
31
- locale = lang if langs.include? lang
32
- end
33
- end
34
-
35
- I18n.locale = locale
36
- redirect_to(:back) if params[:locale]
37
- end
38
- end
File without changes
@@ -1,75 +0,0 @@
1
- class PagesController < ApplicationController
2
- # Devise2 and TheRole before_actions
3
- before_action :login_required, except: [:index, :show]
4
- before_action :role_required, except: [:index, :show]
5
-
6
- before_action :set_page, only: [:edit, :update, :destroy]
7
- before_action :owner_required, only: [:edit, :update, :destroy]
8
-
9
- # Public
10
-
11
- def index
12
- @pages = Page.with_state(:published).all
13
- end
14
-
15
- def show
16
- @page = Page.with_state(:published).find params[:id]
17
- end
18
-
19
- # Login && role
20
-
21
- def new
22
- @page = Page.new
23
- end
24
-
25
- def create
26
- @page = Page.new page_params
27
-
28
- if @page.save
29
- redirect_to @page, notice: 'Page was successfully created.'
30
- else
31
- render action: 'new'
32
- end
33
- end
34
-
35
- def my
36
- @pages = current_user.pages
37
- end
38
-
39
- # login && role && ownership
40
-
41
- def edit; end
42
-
43
- def update
44
- if @page.update_attributes page_params
45
- redirect_to @page, notice: 'Page was successfully updated.'
46
- else
47
- render action: :edit
48
- end
49
- end
50
-
51
- def destroy
52
- @page.destroy
53
- redirect_to pages_url
54
- end
55
-
56
- # Admin or Pages Moderator Role require
57
-
58
- def manage
59
- @pages = Page.all
60
- end
61
-
62
- private
63
-
64
- def set_page
65
- @page = Page.find params[:id]
66
-
67
- # TheRole: You should define OWNER CHECK OBJECT
68
- # When editable object was found
69
- @owner_check_object = @page
70
- end
71
-
72
- def page_params
73
- params.require(:page).permit(:user_id, :title, :content, :state)
74
- end
75
- end
@@ -1,32 +0,0 @@
1
- class UsersController < ApplicationController
2
- before_filter :login_required
3
- before_filter :role_required
4
-
5
- before_filter :find_user, :only => [:edit, :update]
6
- before_filter :owner_required, :only => [:edit, :update]
7
-
8
- def edit; end
9
-
10
- def update
11
- @user.update_attributes params[:user]
12
- flash[:notice] = 'User was successfully updated.'
13
- redirect_to edit_user_path @user
14
- end
15
-
16
- def change_role
17
- @user = User.find params[:user_id]
18
- @role = Role.find params[:role_id]
19
- @user.update_attribute(:role, @role)
20
- redirect_to edit_user_path @user
21
- end
22
-
23
- private
24
-
25
- def find_user
26
- @user = User.find params[:id]
27
-
28
- # TheRole: You should define OWNER CHECK OBJECT
29
- # When editable object was found
30
- @owner_check_object = @user
31
- end
32
- end
@@ -1,13 +0,0 @@
1
- class WelcomeController < ApplicationController
2
- before_filter :authenticate_user!, :except => [:index, :autologin]
3
-
4
- def index; end
5
- def profile; end
6
-
7
- def autologin
8
- user = User.find_by_email params[:email]
9
- sign_in user if user
10
- redirect_to request.referrer || root_path
11
- end
12
-
13
- end
@@ -1,2 +0,0 @@
1
- module ApplicationHelper
2
- end
File without changes
File without changes
File without changes
@@ -1,24 +0,0 @@
1
- class Page < ActiveRecord::Base
2
- # RELATIONS
3
- belongs_to :user
4
-
5
- # VALIDATIONS
6
- validates :user, presence: true
7
- validates :title, presence: true, uniqueness: true
8
- validates :content, presence: true
9
-
10
- state_machine :state, :initial => :draft do
11
- # events
12
- event :to_draft do
13
- transition all => :draft
14
- end
15
-
16
- event :to_published do
17
- transition all => :published
18
- end
19
-
20
- event :to_deleted do
21
- transition all => :deleted
22
- end
23
- end
24
- end
@@ -1,4 +0,0 @@
1
- class Role < ActiveRecord::Base
2
- include TheRole::Role
3
- # acts_as_role
4
- end
@@ -1,21 +0,0 @@
1
- class User < ActiveRecord::Base
2
- # Include default devise modules. Others available are:
3
- # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
4
- devise :database_authenticatable, :registerable,
5
- :recoverable, :rememberable, :trackable, :validatable
6
-
7
- include TheRole::User
8
- # has_role
9
-
10
- # Setup accessible (or protected) attributes for your model
11
- # attr_accessible :email, :password, :password_confirmation, :remember_me
12
- # User accessible fields
13
- # attr_accessible :name, :company, :address
14
-
15
- # When we uncomment this string - test should give fail
16
- # just for example, do not uncomment it
17
- # attr_accessible :some_protected_field
18
-
19
- # RELATIONS
20
- has_many :pages
21
- end
@@ -1,17 +0,0 @@
1
- %h2 Current user
2
-
3
- %p
4
- - if user_signed_in?
5
- %p
6
- %b{ style: "color:green" }= current_user.name
7
- %p
8
- %i role: #{current_user.role.name}
9
- \|
10
- = link_to "Sign out", destroy_user_session_path, :method => :delete
11
- - else
12
- %p
13
- %i Guest
14
- %p
15
- = link_to "Sign in", new_user_session_path
16
- \|
17
- = link_to "Sign up", new_user_registration_path