has_moderated 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +75 -0
- data/Rakefile +37 -0
- data/lib/generators/USAGE +9 -0
- data/lib/generators/has_moderated/install/install_generator.rb +24 -0
- data/lib/generators/has_moderated/install/templates/migration.rb +15 -0
- data/lib/generators/has_moderated/install/templates/moderation.rb +60 -0
- data/lib/has_moderated/version.rb +3 -0
- data/lib/has_moderated.rb +128 -0
- data/lib/tasks/has_moderated_tasks.rake +4 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +9 -0
- data/test/dummy/app/assets/stylesheets/application.css +7 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/models/moderation.rb +60 -0
- data/test/dummy/app/models/subtask.rb +3 -0
- data/test/dummy/app/models/task.rb +6 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config/application.rb +50 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +30 -0
- data/test/dummy/config/environments/production.rb +60 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +10 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +58 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20110901013205_create_tasks.rb +10 -0
- data/test/dummy/db/migrate/20110901013228_create_subtasks.rb +11 -0
- data/test/dummy/db/migrate/20110901013618_create_moderations.rb +15 -0
- data/test/dummy/db/schema.rb +39 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +422 -0
- data/test/dummy/log/test.log +2504 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +26 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/dummy/spec/models/task_spec.rb +115 -0
- data/test/dummy/spec/spec_helper.rb +27 -0
- metadata +185 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2011 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
= HasModerated
|
2
|
+
|
3
|
+
== Installing
|
4
|
+
|
5
|
+
gem install has_moderated
|
6
|
+
|
7
|
+
Right now, rubygems.org is having some problems so I can't push the gem, but you can install from this repo by calling
|
8
|
+
|
9
|
+
rake install
|
10
|
+
|
11
|
+
To set up has_moderated in your project, use
|
12
|
+
|
13
|
+
rails generate has_moderated:install
|
14
|
+
|
15
|
+
|
16
|
+
rake db:migrate
|
17
|
+
|
18
|
+
This will generate a Moderation model and a migration for it.
|
19
|
+
|
20
|
+
== Usage
|
21
|
+
To moderate one or more attributes, add
|
22
|
+
|
23
|
+
has_moderated :attr1, :attr2
|
24
|
+
|
25
|
+
to your model.
|
26
|
+
|
27
|
+
If you want to moderate the creation of a record (for example, you don't want new blog posts to show up until they are accepted by a moderator), use
|
28
|
+
|
29
|
+
has_moderated_existance
|
30
|
+
|
31
|
+
You can also specify associations that need to be saved for moderation as well (if moderating the creation of new records) - for example, if a Post has_many :links, and you want to submit these links to moderation as well (note, if you don't, they will be discarded), use
|
32
|
+
|
33
|
+
has_moderated_existance :with_associations => [:links]
|
34
|
+
|
35
|
+
in your Post model (post.rb). This only matters when you use has_moderated_existance.
|
36
|
+
|
37
|
+
Right now it's not possible to moderate deletion (destruction) of records.
|
38
|
+
|
39
|
+
== Manage moderations
|
40
|
+
To see pending moderations, simply call
|
41
|
+
|
42
|
+
Moderation.all
|
43
|
+
|
44
|
+
You can also see moderations for a specific record. For example, if you have Post model, you can call moderations on it.
|
45
|
+
|
46
|
+
post = Post.first
|
47
|
+
post.moderations
|
48
|
+
|
49
|
+
Moderation is a normal ActiveRecord model, you can inspect it in rails console to see what it holds. Data (attr_value) is serialized in YAML format and can be deserialized by calling
|
50
|
+
|
51
|
+
YAML::load(moderation.attr_value)
|
52
|
+
|
53
|
+
To accept a moderation, call
|
54
|
+
|
55
|
+
moderation.accept
|
56
|
+
|
57
|
+
to discard (destroy) it, call
|
58
|
+
|
59
|
+
moderation.discard
|
60
|
+
|
61
|
+
== Tests
|
62
|
+
|
63
|
+
I've tested this project using RSpec. You can find the tests in
|
64
|
+
|
65
|
+
test/dummy/spec/models/task_spec.rb
|
66
|
+
|
67
|
+
You can run the tests by running
|
68
|
+
|
69
|
+
rake spec
|
70
|
+
|
71
|
+
in the root directory.
|
72
|
+
|
73
|
+
== License
|
74
|
+
|
75
|
+
This project rocks and uses MIT-LICENSE.
|
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'HasModerated'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
Bundler::GemHelper.install_tasks
|
26
|
+
|
27
|
+
require 'rake/testtask'
|
28
|
+
|
29
|
+
Rake::TestTask.new(:test) do |t|
|
30
|
+
t.libs << 'lib'
|
31
|
+
t.libs << 'test'
|
32
|
+
t.pattern = 'test/**/*_test.rb'
|
33
|
+
t.verbose = false
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
task :default => :test
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module HasModerated
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < ::Rails::Generators::Base
|
4
|
+
desc "This generator installs files for has_moderated."
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
include Rails::Generators::Migration
|
7
|
+
|
8
|
+
def files
|
9
|
+
class_collisions 'Moderation'
|
10
|
+
template 'moderation.rb', File.join('app/models', 'moderation.rb')
|
11
|
+
migration_template 'migration.rb', 'db/migrate/create_moderations.rb'
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
def self.next_migration_number(dirname) #:nodoc:
|
16
|
+
if ActiveRecord::Base.timestamped_migrations
|
17
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
18
|
+
else
|
19
|
+
"%.3d" % (current_migration_number(dirname) + 1)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class CreateModerations < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table "moderations" do |t|
|
4
|
+
t.integer "moderatable_id", :null => true
|
5
|
+
t.string "moderatable_type", :null => false
|
6
|
+
t.string "attr_name", :limit => 60, :null => false
|
7
|
+
t.text "attr_value", :null => false
|
8
|
+
t.timestamps
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.down
|
13
|
+
drop_table :moderations
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
class Moderation < ActiveRecord::Base
|
2
|
+
belongs_to :moderatable, :polymorphic => true
|
3
|
+
|
4
|
+
def accept
|
5
|
+
# case: moderated existance (new record)
|
6
|
+
if attr_name == '-'
|
7
|
+
# create the main record
|
8
|
+
rec = moderatable_type.constantize.new
|
9
|
+
loaded_val = YAML::load(attr_value)
|
10
|
+
attrs = loaded_val[:main_model]
|
11
|
+
# bypass attr_accessible protection
|
12
|
+
attrs.each_pair do |key, val|
|
13
|
+
rec.send(key.to_s+"=", val) unless key.to_s == 'id'
|
14
|
+
end
|
15
|
+
# temporarily disable moderation check on save, and save updated record
|
16
|
+
rec.has_moderated_updating = true
|
17
|
+
rec.save
|
18
|
+
rec.has_moderated_updating = false
|
19
|
+
|
20
|
+
# check for saved associated records
|
21
|
+
loaded_val[:associations].each_pair do |assoc_name, assoc_records|
|
22
|
+
# read reflections attribute to determine proper class name and primary key
|
23
|
+
assoc_details = rec.class.reflections[assoc_name.to_sym]
|
24
|
+
m = assoc_details.class_name.constantize
|
25
|
+
|
26
|
+
# all records for this associated model
|
27
|
+
assoc_records.each do |attrs|
|
28
|
+
arec = m.new # new associated model
|
29
|
+
attrs.each_pair do |key, val|
|
30
|
+
arec.send(key.to_s+"=", val) unless key.to_s == 'id'
|
31
|
+
end
|
32
|
+
fk = if assoc_details.respond_to?(:foreign_key)
|
33
|
+
assoc_details.foreign_key
|
34
|
+
else # version < 3.1
|
35
|
+
assoc_details.primary_key_name
|
36
|
+
end
|
37
|
+
arec.send(fk.to_s+"=", rec.id) # set association to the newly created record
|
38
|
+
# disable moderation for associated model (if enabled)
|
39
|
+
arec.has_moderated_updating = true if arec.respond_to?("has_moderated_updating=")
|
40
|
+
arec.save
|
41
|
+
arec.has_moderated_updating = false if arec.respond_to?("has_moderated_updating=")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
self.destroy # destroy this moderation since it has been applied
|
45
|
+
rec
|
46
|
+
# case: moderated attribute (existing record)
|
47
|
+
else
|
48
|
+
moderatable.has_moderated_updating = true
|
49
|
+
# bypass attr_accessible protection
|
50
|
+
moderatable.send(attr_name.to_s+"=", YAML::load(attr_value))
|
51
|
+
moderatable.save
|
52
|
+
moderatable.has_moderated_updating = false
|
53
|
+
self.destroy # destroy this moderation since it has been applied
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def discard
|
58
|
+
self.destroy
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
module HasModerated
|
2
|
+
|
3
|
+
def self.included(base)
|
4
|
+
base.send :extend, ClassMethods
|
5
|
+
end
|
6
|
+
|
7
|
+
module ClassMethods
|
8
|
+
def has_moderated *args, &block
|
9
|
+
# Lazily include the instance methods so we don't clutter up
|
10
|
+
# any more ActiveRecord models than we have to.
|
11
|
+
send :include, InstanceMethods
|
12
|
+
|
13
|
+
has_many :moderations, :as => :moderatable, :dependent => :destroy
|
14
|
+
|
15
|
+
cattr_accessor :moderated_attributes
|
16
|
+
|
17
|
+
self.moderated_attributes ||= []
|
18
|
+
|
19
|
+
args.each do |arg|
|
20
|
+
self.moderated_attributes.push(arg.to_s)
|
21
|
+
end
|
22
|
+
|
23
|
+
# use an attribute to temporarily disable moderation before_save filter
|
24
|
+
attr_accessor :has_moderated_updating
|
25
|
+
|
26
|
+
# send moderated attributes to moderation before saving the model
|
27
|
+
before_save do
|
28
|
+
if self.valid? && @has_moderated_updating != true &&
|
29
|
+
# don't save moderated attributes if existance is moderated and it's a new record
|
30
|
+
!(self.class.respond_to?("moderated_existance_options") && new_record?)
|
31
|
+
moderations = self.to_moderation
|
32
|
+
if self.id.blank?
|
33
|
+
@pending_moderations ||= []
|
34
|
+
@pending_moderations.concat(moderations)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# when creating a new record, we must update moderations' id after it is known (after create)
|
40
|
+
after_create do
|
41
|
+
if !self.id.blank? && !@pending_moderations.blank?
|
42
|
+
@pending_moderations.each do |m|
|
43
|
+
m.update_attributes(:moderatable_id => self.id)
|
44
|
+
end
|
45
|
+
@pending_moderations.clear
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def has_moderated_existance options
|
51
|
+
# Lazily include the instance methods so we don't clutter up
|
52
|
+
# any more ActiveRecord models than we have to.
|
53
|
+
send :include, InstanceMethods
|
54
|
+
|
55
|
+
# use an attribute to temporarily disable moderation before_save filter
|
56
|
+
attr_accessor :has_moderated_updating
|
57
|
+
|
58
|
+
# save options for use later
|
59
|
+
cattr_accessor :moderated_existance_options
|
60
|
+
self.moderated_existance_options = options
|
61
|
+
|
62
|
+
alias_method_chain :create_or_update, :moderated_check
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
module InstanceMethods
|
67
|
+
def create_or_update_with_moderated_check *args
|
68
|
+
if valid? && new_record? && @has_moderated_updating != true
|
69
|
+
self.to_moderation_created(self.class.moderated_existance_options)
|
70
|
+
true
|
71
|
+
else
|
72
|
+
create_or_update_without_moderated_check *args
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def to_moderation_created options
|
77
|
+
assocs = []
|
78
|
+
|
79
|
+
unless options.blank?
|
80
|
+
unless options[:with_associations].blank?
|
81
|
+
assocs = options[:with_associations]
|
82
|
+
assocs = [assocs] unless assocs.respond_to?("[]")
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
assoc_attrs = {}
|
87
|
+
assocs.each do |assoc|
|
88
|
+
one_assoc = []
|
89
|
+
self.send(assoc).each do |m|
|
90
|
+
one_assoc.push(m.attributes)
|
91
|
+
end
|
92
|
+
assoc_attrs[assoc] = one_assoc unless one_assoc.empty?
|
93
|
+
end
|
94
|
+
|
95
|
+
attr_value = {
|
96
|
+
:main_model => self.attributes,
|
97
|
+
:associations => assoc_attrs
|
98
|
+
}
|
99
|
+
|
100
|
+
Moderation.create!({
|
101
|
+
:moderatable_type => self.class.to_s,
|
102
|
+
:moderatable_id => self.id,
|
103
|
+
:attr_name => "-",
|
104
|
+
:attr_value => attr_value.to_yaml
|
105
|
+
})
|
106
|
+
end
|
107
|
+
|
108
|
+
def to_moderation
|
109
|
+
moderations = []
|
110
|
+
self.changes.each_pair do |att_name, values|
|
111
|
+
att_name = att_name.to_s
|
112
|
+
next if values[1].blank?
|
113
|
+
if self.class.moderated_attributes.include?(att_name)
|
114
|
+
moderations.push(Moderation.create!({
|
115
|
+
:moderatable_type => self.class.to_s,
|
116
|
+
:moderatable_id => self.id,
|
117
|
+
:attr_name => att_name,
|
118
|
+
:attr_value => self.attributes[att_name].to_yaml
|
119
|
+
}))
|
120
|
+
self.send(att_name+"=", values[0])
|
121
|
+
end
|
122
|
+
end
|
123
|
+
moderations
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
ActiveRecord::Base.send :include, HasModerated
|
data/test/dummy/Rakefile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
#!/usr/bin/env rake
|
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
|
+
Dummy::Application.load_tasks
|
@@ -0,0 +1,9 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into including all the files listed below.
|
2
|
+
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
|
3
|
+
// be included in the compiled file accessible from http://example.com/assets/application.js
|
4
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
5
|
+
// the compiled file.
|
6
|
+
//
|
7
|
+
//= require jquery
|
8
|
+
//= require jquery_ujs
|
9
|
+
//= require_tree .
|
@@ -0,0 +1,7 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll automatically include all the stylesheets available in this directory
|
3
|
+
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
|
4
|
+
* the top of the compiled file, but it's generally better to create a new file per style scope.
|
5
|
+
*= require_self
|
6
|
+
*= require_tree .
|
7
|
+
*/
|
@@ -0,0 +1,60 @@
|
|
1
|
+
class Moderation < ActiveRecord::Base
|
2
|
+
belongs_to :moderatable, :polymorphic => true
|
3
|
+
|
4
|
+
def accept
|
5
|
+
# case: moderated existance (new record)
|
6
|
+
if attr_name == '-'
|
7
|
+
# create the main record
|
8
|
+
rec = moderatable_type.constantize.new
|
9
|
+
loaded_val = YAML::load(attr_value)
|
10
|
+
attrs = loaded_val[:main_model]
|
11
|
+
# bypass attr_accessible protection
|
12
|
+
attrs.each_pair do |key, val|
|
13
|
+
rec.send(key.to_s+"=", val) unless key.to_s == 'id'
|
14
|
+
end
|
15
|
+
# temporarily disable moderation check on save, and save updated record
|
16
|
+
rec.has_moderated_updating = true
|
17
|
+
rec.save
|
18
|
+
rec.has_moderated_updating = false
|
19
|
+
|
20
|
+
# check for saved associated records
|
21
|
+
loaded_val[:associations].each_pair do |assoc_name, assoc_records|
|
22
|
+
# read reflections attribute to determine proper class name and primary key
|
23
|
+
assoc_details = rec.class.reflections[assoc_name.to_sym]
|
24
|
+
m = assoc_details.class_name.constantize
|
25
|
+
|
26
|
+
# all records for this associated model
|
27
|
+
assoc_records.each do |attrs|
|
28
|
+
arec = m.new # new associated model
|
29
|
+
attrs.each_pair do |key, val|
|
30
|
+
arec.send(key.to_s+"=", val) unless key.to_s == 'id'
|
31
|
+
end
|
32
|
+
fk = if assoc_details.respond_to?(:foreign_key)
|
33
|
+
assoc_details.foreign_key
|
34
|
+
else # version < 3.1
|
35
|
+
assoc_details.primary_key_name
|
36
|
+
end
|
37
|
+
arec.send(fk.to_s+"=", rec.id) # set association to the newly created record
|
38
|
+
# disable moderation for associated model (if enabled)
|
39
|
+
arec.has_moderated_updating = true if arec.respond_to?("has_moderated_updating=")
|
40
|
+
arec.save
|
41
|
+
arec.has_moderated_updating = false if arec.respond_to?("has_moderated_updating=")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
self.destroy # destroy this moderation since it has been applied
|
45
|
+
rec
|
46
|
+
# case: moderated attribute (existing record)
|
47
|
+
else
|
48
|
+
moderatable.has_moderated_updating = true
|
49
|
+
# bypass attr_accessible protection
|
50
|
+
moderatable.send(attr_name.to_s+"=", YAML::load(attr_value))
|
51
|
+
moderatable.save
|
52
|
+
moderatable.has_moderated_updating = false
|
53
|
+
self.destroy # destroy this moderation since it has been applied
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def discard
|
58
|
+
self.destroy
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require 'rails/all'
|
4
|
+
|
5
|
+
Bundler.require
|
6
|
+
require "has_moderated"
|
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
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
15
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
16
|
+
|
17
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
18
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
19
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
20
|
+
|
21
|
+
# Activate observers that should always be running.
|
22
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
23
|
+
|
24
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
25
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
26
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
27
|
+
|
28
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
29
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
30
|
+
# config.i18n.default_locale = :de
|
31
|
+
|
32
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
33
|
+
config.encoding = "utf-8"
|
34
|
+
|
35
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
36
|
+
config.filter_parameters += [:password]
|
37
|
+
|
38
|
+
# Enable the asset pipeline
|
39
|
+
config.assets.enabled = true
|
40
|
+
|
41
|
+
# Version of your assets, change this if you want to expire all your assets
|
42
|
+
config.assets.version = '1.0'
|
43
|
+
|
44
|
+
config.generators do |g|
|
45
|
+
g.test_framework :rspec, :fixture => true, :views => false
|
46
|
+
g.fixture_replacement :factory_girl, :dir => "spec/factories"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
@@ -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
|
+
development:
|
7
|
+
adapter: sqlite3
|
8
|
+
database: db/development.sqlite3
|
9
|
+
pool: 5
|
10
|
+
timeout: 5000
|
11
|
+
|
12
|
+
# Warning: The database defined as "test" will be erased and
|
13
|
+
# re-generated from your development database when you run "rake".
|
14
|
+
# Do not set this db to the same as development or production.
|
15
|
+
test:
|
16
|
+
adapter: sqlite3
|
17
|
+
database: db/test.sqlite3
|
18
|
+
pool: 5
|
19
|
+
timeout: 5000
|
20
|
+
|
21
|
+
production:
|
22
|
+
adapter: sqlite3
|
23
|
+
database: db/production.sqlite3
|
24
|
+
pool: 5
|
25
|
+
timeout: 5000
|
@@ -0,0 +1,30 @@
|
|
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
|
+
# Log error messages when you accidentally call methods on nil.
|
10
|
+
config.whiny_nils = true
|
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
|
+
# Only use best-standards-support built into browsers
|
23
|
+
config.action_dispatch.best_standards_support = :builtin
|
24
|
+
|
25
|
+
# Do not compress assets
|
26
|
+
config.assets.compress = false
|
27
|
+
|
28
|
+
# Expands the lines which load the assets
|
29
|
+
config.assets.debug = true
|
30
|
+
end
|