mix-rails 0.22.0 → 0.23.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.
- data/MIX_RAILS_VERSION +1 -1
- data/README.md +4 -13
- data/admix/app/controllers/admix/inherited_controller.rb +13 -1
- data/admix/lib/admix/version.rb +1 -1
- data/admix/spec/spec_helper.rb +3 -7
- data/lib/mix-rails.rb +1 -0
- data/mix-rails-albums/Gemfile +0 -8
- data/mix-rails-albums/app/assets/javascripts/backbone/models/photo.js.coffee +0 -1
- data/mix-rails-albums/app/assets/javascripts/backbone/templates/photos/photo_modal_edit.hamlc.erb +2 -2
- data/mix-rails-albums/app/assets/javascripts/models/fileitem.js +0 -1
- data/mix-rails-albums/app/models/admix/albums_datagrid.rb +1 -1
- data/mix-rails-albums/app/models/admix/photos_datagrid.rb +1 -1
- data/mix-rails-albums/app/models/album.rb +3 -3
- data/mix-rails-albums/app/models/concerns/album.rb +36 -0
- data/mix-rails-albums/app/models/photo.rb +7 -8
- data/mix-rails-albums/app/uploaders/albums/image_uploader.rb +4 -3
- data/mix-rails-albums/db/migrate/20130208020540_create_albums.rb +17 -0
- data/mix-rails-albums/db/migrate/20130208021030_create_photos.rb +15 -0
- data/mix-rails-albums/lib/mix-rails-albums.rb +1 -7
- data/mix-rails-albums/lib/mix-rails-albums/engine.rb +5 -0
- data/mix-rails-albums/lib/mix-rails-albums/version.rb +1 -1
- data/mix-rails-albums/mix-rails-albums.gemspec +0 -3
- data/mix-rails-albums/spec/models/album_spec.rb +5 -0
- data/mix-rails-albums/spec/models/picture_spec.rb +5 -0
- data/mix-rails-auth/Gemfile +0 -1
- data/mix-rails-auth/app/models/admix/roles_datagrid.rb +1 -1
- data/mix-rails-auth/app/models/admix/users_datagrid.rb +1 -1
- data/mix-rails-auth/app/models/role.rb +2 -15
- data/mix-rails-auth/app/models/user.rb +6 -46
- data/mix-rails-auth/config/initializers/devise.rb +2 -2
- data/mix-rails-auth/config/initializers/rolify.rb +1 -1
- data/mix-rails-auth/config/routes.rb +1 -1
- data/mix-rails-auth/db/migrate/20130206200605_devise_create_users.rb +46 -0
- data/mix-rails-auth/db/migrate/20130206200717_rolify_create_roles.rb +19 -0
- data/mix-rails-auth/lib/mix-rails-auth/engine.rb +6 -0
- data/mix-rails-auth/lib/mix-rails-auth/version.rb +1 -1
- data/mix-rails-auth/spec/models/user_spec.rb +5 -0
- data/mix-rails-core/Gemfile +1 -7
- data/mix-rails-core/app/models/admix/categories_datagrid.rb +1 -2
- data/mix-rails-core/app/models/attachment.rb +4 -3
- data/mix-rails-core/app/models/categorization.rb +5 -0
- data/mix-rails-core/app/models/category.rb +3 -2
- data/mix-rails-core/app/models/concerns/attachment.rb +0 -3
- data/mix-rails-core/app/uploaders/core/file_uploader.rb +1 -3
- data/mix-rails-core/config/initializers/carrierwave.rb +1 -5
- data/mix-rails-core/config/initializers/defaults_rails.rb +1 -0
- data/mix-rails-core/config/locales/core.pt-BR.yml +2 -1
- data/mix-rails-core/config/routes.rb +0 -2
- data/mix-rails-core/db/migrate/20130206195145_create_attachments.rb +10 -0
- data/mix-rails-core/db/migrate/20130206195329_create_categories.rb +8 -0
- data/mix-rails-core/db/migrate/20130207132351_create_categorizations.rb +9 -0
- data/mix-rails-core/lib/mix-rails-core.rb +3 -22
- data/mix-rails-core/lib/mix-rails-core/engine.rb +2 -4
- data/mix-rails-core/lib/mix-rails-core/version.rb +1 -1
- data/mix-rails-core/mix-rails-core.gemspec +1 -6
- data/mix-rails-core/spec/models/attachment_spec.rb +5 -0
- data/mix-rails-core/spec/models/categorization_spec.rb +5 -0
- data/mix-rails-core/spec/models/category_spec.rb +5 -0
- data/mix-rails-core/spec/spec_helper.rb +3 -3
- data/mix-rails-message-board/app/controllers/admix/board_messages_controller.rb +2 -2
- data/mix-rails-message-board/app/controllers/board_messages_controller.rb +1 -1
- data/mix-rails-message-board/app/models/admix/board_messages_datagrid.rb +3 -3
- data/mix-rails-message-board/app/models/admix/board_replies_datagrid.rb +3 -3
- data/mix-rails-message-board/app/models/board_message.rb +12 -21
- data/mix-rails-message-board/app/models/board_reply.rb +19 -20
- data/mix-rails-message-board/app/views/admix/board_messages/_form_fields.html.haml +1 -1
- data/mix-rails-message-board/app/views/admix/board_messages/_show.html.haml +4 -4
- data/mix-rails-message-board/app/views/admix/board_messages/_table_actions.html.haml +2 -2
- data/mix-rails-message-board/app/views/admix/board_replies/_form_fields.html.haml +1 -1
- data/mix-rails-message-board/app/views/admix/board_replies/_show.html.haml +2 -2
- data/mix-rails-message-board/app/views/admix/board_replies/_table_actions.html.haml +2 -2
- data/mix-rails-message-board/app/views/board_messages/_board_message.html.haml +1 -1
- data/mix-rails-message-board/config/locales/message-board.pt-BR.yml +6 -1
- data/mix-rails-message-board/db/migrate/20130208130406_create_board_messages.rb +13 -0
- data/mix-rails-message-board/db/migrate/20130208130716_create_board_replies.rb +14 -0
- data/mix-rails-message-board/lib/mix-rails-message-board/version.rb +1 -1
- data/mix-rails-settings/Gemfile +1 -0
- data/mix-rails-settings/app/models/admix/settings_datagrid.rb +1 -1
- data/mix-rails-settings/app/models/setting.rb +11 -18
- data/mix-rails-settings/app/uploaders/settings/image_uploader.rb +2 -3
- data/mix-rails-settings/db/migrate/20130206201915_create_settings.rb +13 -0
- data/mix-rails-settings/db/migrate/20130206212203_add_image_to_setting.rb +5 -0
- data/mix-rails-settings/lib/mix-rails-settings/engine.rb +5 -0
- data/mix-rails-settings/lib/mix-rails-settings/version.rb +1 -1
- data/mix-rails-settings/spec/models/setting_spec.rb +5 -0
- data/mix-rails-songs/app/models/admix/songs_datagrid.rb +1 -1
- data/mix-rails-songs/app/models/song.rb +9 -9
- data/mix-rails-songs/app/uploaders/songs/song_uploader.rb +2 -2
- data/mix-rails-songs/db/migrate/20130208034029_create_songs.rb +14 -0
- data/mix-rails-songs/lib/mix-rails-songs/engine.rb +5 -0
- data/mix-rails-songs/lib/mix-rails-songs/version.rb +1 -1
- data/mix-rails-videos/app/models/video.rb +8 -21
- data/mix-rails-videos/db/migrate/20130208040346_create_videos.rb +21 -0
- data/mix-rails-videos/lib/mix-rails-videos/version.rb +1 -1
- data/mix-rails-vouchers/Gemfile +0 -2
- data/mix-rails-vouchers/app/models/admix/vouchers_datagrid.rb +1 -1
- data/mix-rails-vouchers/app/models/voucher.rb +10 -14
- data/mix-rails-vouchers/app/models/voucher_user.rb +41 -46
- data/mix-rails-vouchers/app/uploaders/vouchers/photo_uploader.rb +2 -2
- data/mix-rails-vouchers/db/migrate/20130208143458_create_vouchers.rb +15 -0
- data/mix-rails-vouchers/db/migrate/20130208143613_create_voucher_users.rb +13 -0
- data/mix-rails-vouchers/lib/mix-rails-vouchers.rb +0 -1
- data/mix-rails-vouchers/lib/mix-rails-vouchers/version.rb +1 -1
- data/mix-rails-vouchers/mix-rails-vouchers.gemspec +0 -1
- data/mix-rails-wireframe/lib/mix-rails-wireframe/version.rb +1 -1
- data/mix-rails-writer/app/controllers/news_controller.rb +2 -2
- data/mix-rails-writer/app/models/admix/news_datagrid.rb +3 -7
- data/mix-rails-writer/app/models/news.rb +0 -1
- data/mix-rails-writer/app/models/post.rb +10 -19
- data/mix-rails-writer/app/uploaders/writer/image_uploader.rb +2 -2
- data/mix-rails-writer/app/views/admix/posts/_form_fields.html.haml +2 -2
- data/mix-rails-writer/app/views/admix/posts/_show.html.haml +2 -2
- data/mix-rails-writer/db/migrate/20130208042530_create_posts.rb +16 -0
- data/mix-rails-writer/lib/mix-rails-writer/engine.rb +5 -0
- data/mix-rails-writer/lib/mix-rails-writer/version.rb +1 -1
- data/mix-rails.gemspec +12 -11
- data/version.rb +1 -1
- metadata +92 -56
- data/mix-rails-albums/lib/concerns/models/album.rb +0 -43
- data/mix-rails-core/app/controllers/gridfs_controller.rb +0 -31
- data/mix-rails-core/config/initializers/mongoid.rb +0 -1
- data/mix-rails-core/lib/mix-rails-core/gridfs.rb +0 -32
- data/mix-rails-vouchers/test/functional/voucher_mailer_test.rb +0 -7
data/MIX_RAILS_VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.23.0
|
data/README.md
CHANGED
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
[](https://travis-ci.org/mixinternet/mix-rails)
|
|
4
4
|
[](https://gemnasium.com/mixinternet/mix-rails)
|
|
5
5
|
|
|
6
|
-
MixRails is a CMS based on Ruby on Rails
|
|
6
|
+
MixRails is a CMS based on Ruby on Rails.
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
## Usage
|
|
10
10
|
|
|
11
11
|
Create a new rails project.
|
|
12
12
|
|
|
13
|
-
$ rails new myproject -T --skip-
|
|
13
|
+
$ rails new myproject -T --skip-bundle --dummy-path=spec/dummy
|
|
14
14
|
|
|
15
15
|
Add this line to your application's Gemfile:
|
|
16
16
|
|
|
@@ -25,20 +25,11 @@ And then execute:
|
|
|
25
25
|
In your config/application.rb add require 'mix-rails/all'.
|
|
26
26
|
|
|
27
27
|
```ruby
|
|
28
|
-
require
|
|
29
|
-
require "action_mailer/railtie"
|
|
30
|
-
require "active_resource/railtie"
|
|
31
|
-
require "sprockets/railtie"
|
|
32
|
-
require "rails/test_unit/railtie"
|
|
33
|
-
|
|
28
|
+
require 'rails/all'
|
|
34
29
|
# After rails requiring mix-rails!!
|
|
35
30
|
require "mix-rails/all"
|
|
36
31
|
```
|
|
37
32
|
|
|
38
|
-
Configure a mongoid instance with:
|
|
39
|
-
|
|
40
|
-
$ rails generate mongoid:config
|
|
41
|
-
|
|
42
33
|
And then run the application
|
|
43
34
|
|
|
44
35
|
$ bundle exec rails server
|
|
@@ -84,5 +75,5 @@ TODO: Add some docs for admix
|
|
|
84
75
|
|
|
85
76
|
## Creating a extension
|
|
86
77
|
|
|
87
|
-
$ rails plugin new mix-rails-pluginame -T --skip-
|
|
78
|
+
$ rails plugin new mix-rails-pluginame -T --skip-bundle --dummy-path=spec/dummy --full
|
|
88
79
|
s
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
module Admix
|
|
2
2
|
class InheritedController < Admix::AdmixController
|
|
3
|
+
helper :all
|
|
3
4
|
|
|
4
5
|
inherit_resources
|
|
6
|
+
include InheritedResources::DSL
|
|
7
|
+
|
|
8
|
+
rescue_from ActiveRecord::DeleteRestrictionError do |exception|
|
|
9
|
+
#resource.errors.add(:base, exception)
|
|
10
|
+
flash[:alert] = I18n.t('errors.dependent')
|
|
11
|
+
redirect_to collection_url
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# destroy! do |success, failure|
|
|
15
|
+
# failure.html { redirect_to polymorphic_path(resource) }
|
|
16
|
+
# end
|
|
5
17
|
|
|
6
18
|
# TODO: Add authorization here.
|
|
7
19
|
|
|
8
|
-
|
|
20
|
+
|
|
9
21
|
|
|
10
22
|
before_filter :generate_datagrid , only: [:index ]
|
|
11
23
|
|
data/admix/lib/admix/version.rb
CHANGED
data/admix/spec/spec_helper.rb
CHANGED
|
@@ -39,20 +39,16 @@ RSpec.configure do |config|
|
|
|
39
39
|
# --seed 1234
|
|
40
40
|
config.order = "random"
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
#DatabaseCleaner.orm = "mongoid"
|
|
44
|
-
#DatabaseCleaner.strategy = :truncation
|
|
45
|
-
|
|
46
42
|
config.before(:suite) do
|
|
47
|
-
DatabaseCleaner
|
|
43
|
+
DatabaseCleaner.strategy = :truncation
|
|
48
44
|
end
|
|
49
45
|
|
|
50
46
|
config.before(:each) do
|
|
51
|
-
DatabaseCleaner
|
|
47
|
+
DatabaseCleaner.start
|
|
52
48
|
end
|
|
53
49
|
|
|
54
50
|
config.after(:each) do
|
|
55
|
-
DatabaseCleaner
|
|
51
|
+
DatabaseCleaner.clean
|
|
56
52
|
end
|
|
57
53
|
|
|
58
54
|
end
|
data/lib/mix-rails.rb
CHANGED
data/mix-rails-albums/Gemfile
CHANGED
|
@@ -12,14 +12,6 @@ end
|
|
|
12
12
|
# jquery-rails is used by the dummy application
|
|
13
13
|
gem "jquery-rails"
|
|
14
14
|
gem "haml-rails"
|
|
15
|
-
gem 'bson_ext'
|
|
16
|
-
gem 'mongo'
|
|
17
|
-
|
|
18
|
-
# gem 'carrierwave'
|
|
19
|
-
# gem 'carrierwave-mongoid', require: 'carrierwave/mongoid'
|
|
20
|
-
# gem 'mini_magick'
|
|
21
|
-
#
|
|
22
|
-
gem "carrierwave-mongoid", :git => "git://github.com/jnicklas/carrierwave-mongoid.git", :branch => "master"
|
|
23
15
|
gem 'mini_magick', :git => 'git://github.com/probablycorey/mini_magick.git'
|
|
24
16
|
|
|
25
17
|
# Declare any dependencies that are still in development here instead of in
|
data/mix-rails-albums/app/assets/javascripts/backbone/templates/photos/photo_modal_edit.hamlc.erb
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
.modal.hide.fade.admix-photo-modal{id: "photo-modal-#{@
|
|
1
|
+
.modal.hide.fade.admix-photo-modal{id: "photo-modal-#{@id}"}
|
|
2
2
|
.modal-header
|
|
3
3
|
%button.close{"aria-hidden" => "true", "data-dismiss" => "modal", :type => "button"} ×
|
|
4
4
|
%h3 Detalhes da foto
|
|
5
5
|
.modal-body
|
|
6
6
|
.edit-area.pull-right
|
|
7
|
-
%textarea.span5{id: "input_photo_description_#{@
|
|
7
|
+
%textarea.span5{id: "input_photo_description_#{@id}",placeholder: 'Adicione uma descrição para esta foto.'}
|
|
8
8
|
#{@description}
|
|
9
9
|
.photo
|
|
10
10
|
%img{src: @image.medium.url}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
class Album
|
|
2
|
-
include
|
|
3
|
-
end
|
|
1
|
+
class Album < ActiveRecord::Base
|
|
2
|
+
include Concerns::Album
|
|
3
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
module Concerns::Album
|
|
2
|
+
extend ActiveSupport::Concern
|
|
3
|
+
|
|
4
|
+
included do
|
|
5
|
+
extend Enumerize
|
|
6
|
+
extend FriendlyId
|
|
7
|
+
|
|
8
|
+
attr_accessible :date, :description, :status, :title
|
|
9
|
+
|
|
10
|
+
enumerize :status, in: [:published, :unpublished], default: :published, predicates: true
|
|
11
|
+
friendly_id :title, use: :slugged
|
|
12
|
+
|
|
13
|
+
has_many :photos, :as => :related
|
|
14
|
+
belongs_to :related, :polymorphic => true
|
|
15
|
+
|
|
16
|
+
validation_for_title
|
|
17
|
+
validation_for_date
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
scope :published, where(status: :published).joins(:photos).having("count(photos.id) > 1")
|
|
21
|
+
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
module ClassMethods
|
|
25
|
+
|
|
26
|
+
def validation_for_title
|
|
27
|
+
validates_presence_of :title
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def validation_for_date
|
|
31
|
+
validates_presence_of :date
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
end
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
class Photo
|
|
2
|
-
|
|
3
|
-
include Mongoid::Document
|
|
4
|
-
include Mongoid::Timestamps
|
|
1
|
+
class Photo < ActiveRecord::Base
|
|
2
|
+
extend FriendlyId
|
|
5
3
|
|
|
6
|
-
|
|
4
|
+
attr_accessible :description, :image, :image_cache
|
|
7
5
|
|
|
8
|
-
|
|
6
|
+
friendly_id :description, use: :slugged
|
|
9
7
|
|
|
8
|
+
belongs_to :related, :polymorphic => true
|
|
9
|
+
|
|
10
10
|
mount_uploader :image, Albums::ImageUploader
|
|
11
|
-
|
|
12
|
-
end
|
|
11
|
+
end
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
require 'carrierwave/processing/mini_magick'
|
|
3
|
-
require 'mix-rails-core/gridfs'
|
|
4
3
|
|
|
5
4
|
class Albums::ImageUploader < CarrierWave::Uploader::Base
|
|
6
5
|
|
|
@@ -13,13 +12,13 @@ class Albums::ImageUploader < CarrierWave::Uploader::Base
|
|
|
13
12
|
include Sprockets::Helpers::IsolatedHelper
|
|
14
13
|
|
|
15
14
|
# Choose what kind of storage to use for this uploader:
|
|
16
|
-
|
|
15
|
+
|
|
17
16
|
# storage :fog
|
|
18
17
|
|
|
19
18
|
# Override the directory where uploaded files will be stored.
|
|
20
19
|
# This is a sensible default for uploaders that are meant to be mounted:
|
|
21
20
|
def store_dir
|
|
22
|
-
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
|
21
|
+
"system/uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
|
23
22
|
end
|
|
24
23
|
|
|
25
24
|
def cache_dir
|
|
@@ -51,6 +50,8 @@ class Albums::ImageUploader < CarrierWave::Uploader::Base
|
|
|
51
50
|
|
|
52
51
|
albums_watermark = Setting.albums_watermark
|
|
53
52
|
|
|
53
|
+
#raise albums_watermark.image
|
|
54
|
+
|
|
54
55
|
watermark_image = if albums_watermark
|
|
55
56
|
gridfs_file = MixRailsCore::Gridfs::read_file(albums_watermark.image.url)
|
|
56
57
|
MiniMagick::Image.read(gridfs_file, "png")
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
class CreateAlbums < ActiveRecord::Migration
|
|
2
|
+
def change
|
|
3
|
+
create_table :albums do |t|
|
|
4
|
+
t.string :title
|
|
5
|
+
t.text :description
|
|
6
|
+
t.date :date
|
|
7
|
+
t.string :status
|
|
8
|
+
t.string :slug
|
|
9
|
+
|
|
10
|
+
t.references :related, polymorphic: true
|
|
11
|
+
t.timestamps
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
add_index :albums, :slug, unique: true
|
|
15
|
+
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
class CreatePhotos < ActiveRecord::Migration
|
|
2
|
+
def change
|
|
3
|
+
create_table :photos do |t|
|
|
4
|
+
t.text :description
|
|
5
|
+
t.string :image
|
|
6
|
+
t.string :slug
|
|
7
|
+
|
|
8
|
+
t.references :related, polymorphic: true
|
|
9
|
+
t.timestamps
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
add_index :photos, :slug, unique: true
|
|
13
|
+
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
require "mix-rails-albums/engine"
|
|
2
|
-
|
|
3
|
-
require "mongoid/railtie"
|
|
4
|
-
require "carrierwave/mongoid"
|
|
5
2
|
require "mini_magick"
|
|
6
|
-
|
|
7
3
|
require "haml_coffee_assets"
|
|
8
4
|
|
|
9
5
|
module MixRailsAlbums
|
|
@@ -11,6 +7,4 @@ module MixRailsAlbums
|
|
|
11
7
|
module Models
|
|
12
8
|
end
|
|
13
9
|
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
require 'concerns/models/album'
|
|
10
|
+
end
|
|
@@ -16,9 +16,6 @@ Gem::Specification.new do |s|
|
|
|
16
16
|
s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.rdoc"]
|
|
17
17
|
|
|
18
18
|
s.add_dependency "rails", "~> 3.2.9"
|
|
19
|
-
s.add_dependency 'bson_ext'
|
|
20
|
-
s.add_dependency 'mongo'
|
|
21
|
-
s.add_dependency 'carrierwave-mongoid'
|
|
22
19
|
s.add_dependency 'mini_magick'
|
|
23
20
|
s.add_dependency 'haml_coffee_assets'
|
|
24
21
|
|
data/mix-rails-auth/Gemfile
CHANGED
|
@@ -1,19 +1,6 @@
|
|
|
1
|
-
class Role
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
has_and_belongs_to_many :users
|
|
1
|
+
class Role < ActiveRecord::Base
|
|
2
|
+
has_and_belongs_to_many :users, :join_table => :users_roles
|
|
5
3
|
belongs_to :resource, :polymorphic => true
|
|
6
4
|
|
|
7
|
-
field :name, :type => String
|
|
8
|
-
index({ :name => 1 }, { :unique => true })
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
index({
|
|
12
|
-
:name => 1,
|
|
13
|
-
:resource_type => 1,
|
|
14
|
-
:resource_id => 1
|
|
15
|
-
},
|
|
16
|
-
{ :unique => true})
|
|
17
|
-
|
|
18
5
|
scopify
|
|
19
6
|
end
|
|
@@ -1,52 +1,12 @@
|
|
|
1
|
-
class User
|
|
2
|
-
include Mongoid::Document
|
|
1
|
+
class User < ActiveRecord::Base
|
|
3
2
|
rolify
|
|
4
|
-
include Authority::UserAbilities
|
|
5
|
-
|
|
6
|
-
ROLES = %w[admin manager]
|
|
7
|
-
|
|
8
3
|
# Include default devise modules. Others available are:
|
|
9
4
|
# :token_authenticatable, :confirmable,
|
|
10
5
|
# :lockable, :timeoutable and :omniauthable
|
|
11
|
-
devise :database_authenticatable, :
|
|
12
|
-
:
|
|
13
|
-
|
|
14
|
-
## Database authenticatable
|
|
15
|
-
field :email, :type => String, :default => ""
|
|
16
|
-
field :encrypted_password, :type => String, :default => ""
|
|
17
|
-
|
|
18
|
-
validates_presence_of :email
|
|
19
|
-
validates_presence_of :encrypted_password
|
|
20
|
-
|
|
21
|
-
## Recoverable
|
|
22
|
-
field :reset_password_token, :type => String
|
|
23
|
-
field :reset_password_sent_at, :type => Time
|
|
24
|
-
|
|
25
|
-
## Rememberable
|
|
26
|
-
field :remember_created_at, :type => Time
|
|
27
|
-
|
|
28
|
-
## Trackable
|
|
29
|
-
field :sign_in_count, :type => Integer, :default => 0
|
|
30
|
-
field :current_sign_in_at, :type => Time
|
|
31
|
-
field :last_sign_in_at, :type => Time
|
|
32
|
-
field :current_sign_in_ip, :type => String
|
|
33
|
-
field :last_sign_in_ip, :type => String
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
## Confirmable
|
|
37
|
-
# field :confirmation_token, :type => String
|
|
38
|
-
# field :confirmed_at, :type => Time
|
|
39
|
-
# field :confirmation_sent_at, :type => Time
|
|
40
|
-
# field :unconfirmed_email, :type => String # Only if using reconfirmable
|
|
41
|
-
|
|
42
|
-
## Lockable
|
|
43
|
-
# field :failed_attempts, :type => Integer, :default => 0 # Only if lock strategy is :failed_attempts
|
|
44
|
-
# field :unlock_token, :type => String # Only if unlock strategy is :email or :both
|
|
45
|
-
# field :locked_at, :type => Time
|
|
46
|
-
|
|
47
|
-
## Token authenticatable
|
|
48
|
-
# field :authentication_token, :type => String
|
|
49
|
-
|
|
50
|
-
#has_and_belongs_to_many :roles
|
|
6
|
+
devise :database_authenticatable, :registerable,
|
|
7
|
+
:recoverable, :rememberable, :trackable, :validatable
|
|
51
8
|
|
|
9
|
+
# Setup accessible (or protected) attributes for your model
|
|
10
|
+
attr_accessible :email, :password, :password_confirmation, :remember_me
|
|
11
|
+
# attr_accessible :title, :body
|
|
52
12
|
end
|