formgroups-rails 0.0.2
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/MIT-LICENSE +20 -0
- data/Rakefile +17 -0
- data/lib/form_groups/field_builder.rb +94 -0
- data/lib/form_groups/field_tag.rb +23 -0
- data/lib/form_groups/group_builder.rb +21 -0
- data/lib/form_groups/version.rb +3 -0
- data/lib/formgroups-rails.rb +3 -0
- data/test/dummy/Rakefile +3 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/javascripts/home.js +2 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/assets/stylesheets/home.css +4 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/controllers/home_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/helpers/home_helper.rb +2 -0
- data/test/dummy/app/models/person.rb +2 -0
- data/test/dummy/app/views/home/index.html.erb +18 -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/application.rb +18 -0
- data/test/dummy/config/boot.rb +4 -0
- data/test/dummy/config/database.yml +12 -0
- data/test/dummy/config/environment.rb +3 -0
- data/test/dummy/config/environments/development.rb +15 -0
- data/test/dummy/config/environments/test.rb +16 -0
- data/test/dummy/config/routes.rb +3 -0
- data/test/dummy/config/secrets.yml +5 -0
- data/test/dummy/config.ru +2 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20150504230241_create_people.rb +10 -0
- data/test/dummy/db/schema.rb +23 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +315 -0
- data/test/dummy/log/test.log +20 -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/test/controllers/home_controller_test.rb +9 -0
- data/test/dummy/test/fixtures/people.yml +9 -0
- data/test/dummy/test/models/person_test.rb +7 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/0riukRh6WZ7Sjjvlksv_yGt0IA7scqlLJMgabgG_-5o.cache +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/47_JU9U0dZtuq5KALKGjQHmKu4rnKjY8ZTie2CmIsIo.cache +1 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/AZi3eistqLQcFTFVsRYNCT3_fL88r9mVe0n1D-QvJDs.cache +2 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/AavMJojef3peC9Irw-4GMyBfRkYtQkrOiJqOoKeqQS4.cache +1 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/DlLR4N2dA9aZj7WoSLRzKsbsIRPaU_DGVMUIsAmz1mI.cache +1 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/M1b3JRkxKB-QsJ6I62Q0M7FXEfnw9Lo51rTlpqZ1ACk.cache +1 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/N77w71hD6tVyOOD6bXcf8Ht6H3eXdij-MIaA_y88dWs.cache +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/Ps94uPcSG5YcgPL_OArd_fddiPbzx6si3CAVaPZmyXE.cache +2 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/PzJln2ImbwoAj3mn133dfP5LtCHIzqAgp_F_8CSKU8Q.cache +2 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/QvhAN1d4UDYd4k-Q_PbEI-2qHT5tPA-OordBT-DsytU.cache +1 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/SMbXpDQDCa0Oa3bWohbN9nuTxFDQONzWgzee5JbT_nk.cache +1 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/S_iGa-CGuERHidPjS-PSMPuq8cvaUS8kkRgtwzJNMpk.cache +2 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/VmeLeQXRekR3gXKf400xpQg-7oj76k5052Irhth6d_E.cache +1 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/YNQbfQedUs-5m9VZfatoa_jz6qfqUHh97mdUVMWrwNw.cache +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/Ylfe6vX3JJv4czrwbox-D_iRPjVHjKjP_irMFTUoDbQ.cache +2 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/ZTOK7yGAJ-GFGb-rTcwBzvacpN-rW6EH2ELctZCTUP0.cache +1 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/Znv4NRIkGKuLTr58-Y2pG_lt_glbFjOI9MGYhh6gqHQ.cache +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/_5PWptksXKbekESnPgkrIR1nLlJa4ObY_vFds6ng4g8.cache +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/bRdF0bJkFKmH3B5lFQF4YQu_-m0OocWpOrqefpRlBIg.cache +2 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/e1VBLkDyGa39LAW8WmEwDX34l6Gij08Kj7tUFjJnA3U.cache +2 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/jNi3cFbohn41IpVKflAANlnwugg8nTpYu-MBTCZG-lc.cache +1 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/nqyu6PMmP3PX7E7eiM5w8WqFq7cHY7V2LuzAbu8lhmE.cache +1 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/p_tpINGaRsf_KU5Z-BqmwLD2zl8ZQ7qx6VQImI57bR8.cache +1 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/tOZ0F8GyCoHyQPbLm5-I22oareYKl2Z48N4yaZlnHTU.cache +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/47_JU9U0dZtuq5KALKGjQHmKu4rnKjY8ZTie2CmIsIo.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/50TwRqsGeoLcbrpksPONL6oaV1V5fm4exhCepjPeKj4.cache +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/72EBUT6d77ZV_AQ-WcGi5caiAapjkGhZprVi0LuLcx4.cache +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/AZi3eistqLQcFTFVsRYNCT3_fL88r9mVe0n1D-QvJDs.cache +2 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/AavMJojef3peC9Irw-4GMyBfRkYtQkrOiJqOoKeqQS4.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/LUxdNgtFjUXUvGIaWQtANkM9sUdb_VMJ8G8glB9xQLY.cache +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/Lnsjb99eN4oNtdZtovXcNVs8yT109O4taZkJGyxMFbE.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/M1b3JRkxKB-QsJ6I62Q0M7FXEfnw9Lo51rTlpqZ1ACk.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/Ps94uPcSG5YcgPL_OArd_fddiPbzx6si3CAVaPZmyXE.cache +2 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/PzJln2ImbwoAj3mn133dfP5LtCHIzqAgp_F_8CSKU8Q.cache +2 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/QVO06ory_nNzXOToM_1JPuUBMKmdsvks5AJHfOrmwG4.cache +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/QvhAN1d4UDYd4k-Q_PbEI-2qHT5tPA-OordBT-DsytU.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/S_iGa-CGuERHidPjS-PSMPuq8cvaUS8kkRgtwzJNMpk.cache +2 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/UEew5DsFvRxpggBGgf6rZ4rWPTTXNHuS8_-8mUD69ew.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/Ylfe6vX3JJv4czrwbox-D_iRPjVHjKjP_irMFTUoDbQ.cache +2 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/bRdF0bJkFKmH3B5lFQF4YQu_-m0OocWpOrqefpRlBIg.cache +2 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/e1VBLkDyGa39LAW8WmEwDX34l6Gij08Kj7tUFjJnA3U.cache +2 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/fid3AXHOqJt42f4puodw6G5mhqKCvVKkbLiAMOA74Ys.cache +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/iRW9XpmCm-DgQ1ubno3T6_BeOXpHN3OATlkTgl0sMAg.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/jNi3cFbohn41IpVKflAANlnwugg8nTpYu-MBTCZG-lc.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/lP5Unh1jHMwveypD4lOKCL6--jObsMyxkSOzPr0HUi0.cache +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/s-pgwuN2O2LzTjYS6cnHdnH9b1e_PHqPm5oIt2izuyQ.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/sHDrLLp5ZPrQknTqotKcNoRgMU4atfgAlyd9YAXz2J0.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/vZBE8U_MfTCNwCoaI0iMvWjPI9c7_Atw9ofvvSxbVC4.cache +1 -0
- data/test/form_groups_test.rb +7 -0
- data/test/test_helper.rb +19 -0
- metadata +299 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 93fde5dee9f675b8cfc6f6e07a72db50d85bbe7d
|
4
|
+
data.tar.gz: 82a6b8f7cb99c58a0c70e3ef1daf46cb0388d366
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e371cdc1ee2fb9104da7c816aeed5788e4ab04acefed1f892fb6108592ce227f0269c3819d13922dd3eb476e7d2a6c2b0a701ec38b0175fd7f2da5ccb54ca94c
|
7
|
+
data.tar.gz: 5e218f6209fcfd294d06facc9a3116fd1567c6847afe28662dc573d044f494c60210aef3ec35fc16628f2f198dc861fb3778f8cf12a60ec2a5e4dd9e58bc9f7e
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2015 Alexey Chernetsov
|
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/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'bundler/gem_tasks'
|
8
|
+
require 'rake/testtask'
|
9
|
+
|
10
|
+
Rake::TestTask.new(:test) do |t|
|
11
|
+
t.libs << 'lib'
|
12
|
+
t.libs << 'test'
|
13
|
+
t.pattern = 'test/**/*_test.rb'
|
14
|
+
t.verbose = false
|
15
|
+
end
|
16
|
+
|
17
|
+
task default: :test
|
@@ -0,0 +1,94 @@
|
|
1
|
+
module FormGroups
|
2
|
+
class FieldBuilder
|
3
|
+
FIELD_HELPERS = [:text, :password, :hidden, :file, :color, :search, :telephone, :phone,
|
4
|
+
:date, :time, :datetime, :datetime_local, :month, :week, :url, :email,
|
5
|
+
:number, :range]
|
6
|
+
|
7
|
+
OTHER_HELPERS = [:check_box, :radio_button]
|
8
|
+
|
9
|
+
FIELD_HELPERS.each do |selector|
|
10
|
+
define_method selector do |placeholder = nil, options = {}|
|
11
|
+
options[:placeholder] = placeholder
|
12
|
+
|
13
|
+
@template.send "#{selector}_field".freeze, @method, validated_options(options)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
OTHER_HELPERS.each do |selector|
|
18
|
+
define_method selector do |options = {}|
|
19
|
+
@template.send selector, @method, validated_options(options)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def initialize object_name, method, object, template, options
|
24
|
+
@method , @object_name, @object = method , object_name, object
|
25
|
+
@template, @options = template, options
|
26
|
+
|
27
|
+
@default_options = @options ? @options.slice(:index, :namespace) : {}
|
28
|
+
end
|
29
|
+
|
30
|
+
def errors
|
31
|
+
@object.errors[@method]
|
32
|
+
end
|
33
|
+
|
34
|
+
def label text, options = {}
|
35
|
+
@template.label @method, text, unvalidated_options(options)
|
36
|
+
end
|
37
|
+
|
38
|
+
def text_area placeholder = nil, **options
|
39
|
+
options[:placeholder ] = placeholder
|
40
|
+
options['aria-multiline'] = true
|
41
|
+
|
42
|
+
@template.text_area @method, validated_options(options)
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def unvalidated_options options
|
48
|
+
@default_options.merge(options).merge(object: @object)
|
49
|
+
end
|
50
|
+
|
51
|
+
def validated_options options
|
52
|
+
options = unvalidated_options(options).merge(validations)
|
53
|
+
options = options.merge('aria-invalid' => 'true') if errors.any?
|
54
|
+
|
55
|
+
options
|
56
|
+
end
|
57
|
+
|
58
|
+
def validations
|
59
|
+
validations = validators.map do |validator|
|
60
|
+
result = {}
|
61
|
+
|
62
|
+
case validator
|
63
|
+
when ActiveModel::Validations::LengthValidator
|
64
|
+
result['data-min'] = validator.options[:minimum] if validator.options[:minimum]
|
65
|
+
result['data-max'] = validator.options[:maximum] if validator.options[:maximum]
|
66
|
+
when ActiveRecord::Validations::PresenceValidator
|
67
|
+
result['data-required'] = 'true'
|
68
|
+
result['aria-required'] = 'true'
|
69
|
+
when EmailValidator
|
70
|
+
pattern = EmailValidator::PATTERN.source
|
71
|
+
pattern = pattern.sub('\\A','^')
|
72
|
+
.sub('\\Z','$')
|
73
|
+
.sub('\\z','$')
|
74
|
+
.sub(/^\//,'')
|
75
|
+
.sub(/\/[a-z]*$/,'')
|
76
|
+
.gsub(/\(\?#.+\)/, '')
|
77
|
+
.gsub(/\(\?-\w+:/,'(')
|
78
|
+
|
79
|
+
result['data-pattern'] = pattern
|
80
|
+
end
|
81
|
+
|
82
|
+
result
|
83
|
+
end
|
84
|
+
|
85
|
+
Hash[*validations.collect{ |h| h.to_a }.flatten]
|
86
|
+
end
|
87
|
+
|
88
|
+
def validators
|
89
|
+
@object.class.validators.select do |validator|
|
90
|
+
validator.attributes.include? @method
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module FormGroups
|
2
|
+
class FieldTag < ActionView::Helpers::Tags::Base
|
3
|
+
def initialize object_name, method, object, template, form, options
|
4
|
+
super object_name, method, template, options.merge(object: object)
|
5
|
+
|
6
|
+
@builder = FieldBuilder.new object_name, method, object, form, options
|
7
|
+
end
|
8
|
+
|
9
|
+
def render &block
|
10
|
+
html_options = @options.delete(:html) || {}
|
11
|
+
|
12
|
+
classes = (html_options[:class] || '').split(' ')
|
13
|
+
classes << 'field'
|
14
|
+
classes << 'field-errors' if object.errors.has_key?(@method_name.to_sym)
|
15
|
+
|
16
|
+
html_options[:class] = classes
|
17
|
+
|
18
|
+
output = @template_object.tag(:div, html_options, true)
|
19
|
+
output << @template_object.capture(@builder, &block)
|
20
|
+
output.safe_concat '</div>'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module FormGroups
|
2
|
+
module GroupBuilder
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
def field method, options = {}, &block
|
7
|
+
raise ArgumentError, "Missing block" unless block_given?
|
8
|
+
|
9
|
+
FieldTag.new(object_name, method, object, @template, self, options).render(&block)
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def objectify options
|
15
|
+
options.merge(object: object)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
ActionView::Helpers::FormBuilder.send :include, FormGroups::GroupBuilder
|
data/test/dummy/Rakefile
ADDED
@@ -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,18 @@
|
|
1
|
+
<%= form_for @person do |f| %>
|
2
|
+
<div class='field<%= ' field-errors' if @person.errors[:name].any? %>'>
|
3
|
+
<%= f.label :name, 'Name' %>
|
4
|
+
<%= f.text_field :name, placeholder: 'Name' %>
|
5
|
+
|
6
|
+
<% if @person.errors[:name].any? %>
|
7
|
+
<p><%= @person.errors[:name].first %></p>
|
8
|
+
<% end %>
|
9
|
+
</div>
|
10
|
+
|
11
|
+
<%= f.field :name do |name| %>
|
12
|
+
<%= name.label 'Name' %>
|
13
|
+
<%= name.text 'Name' %>
|
14
|
+
<% if name.errors.any? %>
|
15
|
+
<p><%= name.errors.first %></p>
|
16
|
+
<% end %>
|
17
|
+
<% end %>
|
18
|
+
<% end %>
|
@@ -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,18 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require 'rails/all'
|
4
|
+
|
5
|
+
Bundler.require(*Rails.groups)
|
6
|
+
|
7
|
+
require "formgroups-rails"
|
8
|
+
|
9
|
+
module Dummy
|
10
|
+
class Application < Rails::Application
|
11
|
+
config.assets.version = '1.0'
|
12
|
+
config.active_record.raise_in_transactional_callbacks = true
|
13
|
+
config.action_dispatch.cookies_serializer = :json
|
14
|
+
config.session_store :cookie_store, key: '_dummy_session'
|
15
|
+
config.filter_parameters += [:password]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Rails.application.configure do
|
2
|
+
config.cache_classes = false
|
3
|
+
config.eager_load = false
|
4
|
+
config.consider_all_requests_local = true
|
5
|
+
|
6
|
+
config.action_controller.perform_caching = false
|
7
|
+
config.action_mailer.raise_delivery_errors = false
|
8
|
+
|
9
|
+
config.active_support.deprecation = :log
|
10
|
+
config.active_record.migration_error = :page_load
|
11
|
+
|
12
|
+
config.assets.debug = true
|
13
|
+
config.assets.digest = true
|
14
|
+
config.assets.raise_runtime_errors = true
|
15
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Rails.application.configure do
|
2
|
+
config.cache_classes = true
|
3
|
+
config.eager_load = false
|
4
|
+
config.consider_all_requests_local = true
|
5
|
+
|
6
|
+
config.action_controller.perform_caching = false
|
7
|
+
config.action_mailer.delivery_method = :test
|
8
|
+
config.action_dispatch.show_exceptions = false
|
9
|
+
config.action_controller.allow_forgery_protection = false
|
10
|
+
|
11
|
+
config.active_support.test_order = :random
|
12
|
+
config.active_support.deprecation = :stderr
|
13
|
+
|
14
|
+
config.serve_static_files = true
|
15
|
+
config.static_cache_control = 'public, max-age=3600'
|
16
|
+
end
|
@@ -0,0 +1,5 @@
|
|
1
|
+
development:
|
2
|
+
secret_key_base: 7efbcca2d6c3df78fd085085641a0203161b85820f80f2a0352d738ed2b9a59d04ae6f50f64567968a82ee3db59b807e81d0dff82fe124d9d0bffb01a0d26d20
|
3
|
+
|
4
|
+
test:
|
5
|
+
secret_key_base: c5b91e76e7a414d0a8c24d39078005f2aa53a21b0dbc838f60ae458c96c2f7c9b227cf670987be8a8183f56dfc9700093c7368aa61f156ae65b321e2afa29f6a
|
Binary file
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# This file is auto-generated from the current state of the database. Instead
|
3
|
+
# of editing this file, please use the migrations feature of Active Record to
|
4
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
5
|
+
#
|
6
|
+
# Note that this schema.rb definition is the authoritative source for your
|
7
|
+
# database schema. If you need to create the application database on another
|
8
|
+
# system, you should be using db:schema:load, not running all the migrations
|
9
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
10
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
11
|
+
#
|
12
|
+
# It's strongly recommended that you check this file into your version control system.
|
13
|
+
|
14
|
+
ActiveRecord::Schema.define(version: 20150504230241) do
|
15
|
+
|
16
|
+
create_table "people", force: :cascade do |t|
|
17
|
+
t.string "name"
|
18
|
+
t.string "age"
|
19
|
+
t.datetime "created_at", null: false
|
20
|
+
t.datetime "updated_at", null: false
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
Binary file
|