simple_bootstrap_form 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/.ruby-gemset +1 -0
  4. data/.ruby-version +1 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +74 -0
  8. data/Rakefile +1 -0
  9. data/lib/simple_bootstrap_form/action_view_extensions.rb +31 -0
  10. data/lib/simple_bootstrap_form/css_class_list.rb +32 -0
  11. data/lib/simple_bootstrap_form/fields/base_field.rb +103 -0
  12. data/lib/simple_bootstrap_form/fields/boolean_field.rb +14 -0
  13. data/lib/simple_bootstrap_form/fields/datetime_field.rb +53 -0
  14. data/lib/simple_bootstrap_form/fields/email_field.rb +8 -0
  15. data/lib/simple_bootstrap_form/fields/password_field.rb +8 -0
  16. data/lib/simple_bootstrap_form/fields/text_field.rb +8 -0
  17. data/lib/simple_bootstrap_form/fields/textarea_field.rb +12 -0
  18. data/lib/simple_bootstrap_form/form_builder.rb +51 -0
  19. data/lib/simple_bootstrap_form/version.rb +3 -0
  20. data/lib/simple_bootstrap_form.rb +13 -0
  21. data/simple_bootstrap_form.gemspec +27 -0
  22. data/spec/dummy/.rspec +1 -0
  23. data/spec/dummy/README.rdoc +28 -0
  24. data/spec/dummy/Rakefile +6 -0
  25. data/spec/dummy/app/assets/images/.keep +0 -0
  26. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  27. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  28. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  29. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  30. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  31. data/spec/dummy/app/mailers/.keep +0 -0
  32. data/spec/dummy/app/models/.keep +0 -0
  33. data/spec/dummy/app/models/account.rb +6 -0
  34. data/spec/dummy/app/models/article.rb +2 -0
  35. data/spec/dummy/app/models/concerns/.keep +0 -0
  36. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  37. data/spec/dummy/bin/bundle +3 -0
  38. data/spec/dummy/bin/rails +4 -0
  39. data/spec/dummy/bin/rake +4 -0
  40. data/spec/dummy/config/application.rb +23 -0
  41. data/spec/dummy/config/boot.rb +5 -0
  42. data/spec/dummy/config/database.yml +25 -0
  43. data/spec/dummy/config/environment.rb +5 -0
  44. data/spec/dummy/config/environments/development.rb +29 -0
  45. data/spec/dummy/config/environments/production.rb +80 -0
  46. data/spec/dummy/config/environments/test.rb +36 -0
  47. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  48. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  49. data/spec/dummy/config/initializers/inflections.rb +16 -0
  50. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  51. data/spec/dummy/config/initializers/secret_token.rb +12 -0
  52. data/spec/dummy/config/initializers/session_store.rb +3 -0
  53. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  54. data/spec/dummy/config/locales/en.yml +23 -0
  55. data/spec/dummy/config/routes.rb +60 -0
  56. data/spec/dummy/config.ru +4 -0
  57. data/spec/dummy/db/migrate/20131210035839_create_accounts.rb +14 -0
  58. data/spec/dummy/db/migrate/20140214204510_create_articles.rb +14 -0
  59. data/spec/dummy/db/schema.rb +38 -0
  60. data/spec/dummy/lib/assets/.keep +0 -0
  61. data/spec/dummy/public/404.html +58 -0
  62. data/spec/dummy/public/422.html +58 -0
  63. data/spec/dummy/public/500.html +57 -0
  64. data/spec/dummy/public/favicon.ico +0 -0
  65. data/spec/simple_bootstrap_form_spec.rb +156 -0
  66. data/spec/spec_helper.rb +47 -0
  67. data/spec/support/input_matchers.rb +72 -0
  68. metadata +241 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 53a5640dfe3f3bae268c55e04da08106872c1da5
4
+ data.tar.gz: 72d50603af3495d61d91e4a99b847bac467ba40b
5
+ SHA512:
6
+ metadata.gz: 69c87d1324efb67a722367f817286d7db770b7f07e331528d6c9fe5a761447137371396a3850dc906f956795d4064db3f8bddda458f896ecd669ae0949ca751f
7
+ data.tar.gz: 8f02a703c4977a78061a14c66e9668ce17fc403f2b4d95535a2f344fd6a4c567a099967ce10a1afc1df45c9441dd1d0b66c7b14ee3712133bc68302ead1f0641
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ /.idea
2
+ *.gem
3
+ *.rbc
4
+ .bundle
5
+ .config
6
+ .yardoc
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ tmp
17
+ *.sqlite3
18
+ spec/dummy/log/*.log
19
+ spec/dummy/log/*
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ simple_bootstrap_form
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.1.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in my_gem.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Sam Pierson
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,74 @@
1
+ # Bootstrap 3 Form Builder
2
+
3
+ * I'm a fan of [Boootstrap](http://getbootstrap.com/)
4
+ * I'm a fan of [Simple Form](https://github.com/plataformatec/simple_form)
5
+ * Bootstrap 3 was released in August 2013, but as of February 2014 Simple Form
6
+ has yet to support it.
7
+ * If your forms are relatively simple, this gem can be used as a stop-gap
8
+ measure until Simple Form supports Bootstrap 3.
9
+
10
+ People [have been working on Bootstrap 3 support for Simple
11
+ Form](https://github.com/plataformatec/simple_form/issues/857), for 7 months now
12
+ but as yet it has failed to see the light of day.
13
+
14
+ I think the reason for this may be that while Simple Form is configurable using
15
+ an initializer, Bootstrap 3 requires wrapping something in a new way, which
16
+ is going to require a new feature in the base Simple Form framework.
17
+
18
+ SimpleForm is a featurefull generic framework that will layout forms for
19
+ multiple different CSS frameworks (right now Bootstrap 2.3 and Zurb Foundation).
20
+ The challenge with this is that greater flexibility incurs greater complexity in
21
+ imlementation. I believe the continued non-appearance of Simple Form Bootstrap
22
+ 3 support reflects the difficulty people have in working in this more complex
23
+ framework, and getting the results integrated and released.
24
+
25
+ This goal of this gem is to:
26
+
27
+ * Implement a subset of the Simple Form API
28
+ * Layout forms for Bootstrap 3 only
29
+ * Be easier to maintain
30
+
31
+ ## Installation
32
+
33
+ Add this line to your application's Gemfile:
34
+
35
+ gem 'simple_bootstrap_form'
36
+
37
+ And then execute:
38
+
39
+ $ bundle
40
+
41
+ Or install it yourself as:
42
+
43
+ $ gem install simple_bootstrap_form
44
+
45
+ ## Usage
46
+
47
+ Replace calls to:
48
+
49
+ simple_form_for ...
50
+
51
+ with
52
+
53
+ bootstrap_form_for ...
54
+
55
+ ## Support
56
+
57
+ #### Bootstrap Support
58
+
59
+ * Horizontal Form
60
+
61
+ #### Simple Form API Support
62
+
63
+ * Input types: boolean, datetime, email, password, text, textarea. These are
64
+ trivial to add. Just take a look in fields/.
65
+ * Required fields.
66
+ * Placeholders, automatic and custom.
67
+
68
+ ## Contributing
69
+
70
+ 1. Fork it ( http://github.com/<my-github-username>/my_gem/fork )
71
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
72
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
73
+ 4. Push to the branch (`git push origin my-new-feature`)
74
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,31 @@
1
+ module SimpleBootstrapForm
2
+ module ActionViewExtensions
3
+
4
+ def bootstrap_form_for(record, options={}, &block)
5
+ options[:builder] ||= SimpleBootstrapForm::FormBuilder
6
+ options[:html] ||= {}
7
+ options[:html][:class] = CssClassList.new options[:html][:class]
8
+ options[:html][:class] << 'form-horizontal'
9
+ options[:html][:role] ||= 'form'
10
+ prevent_action_view_putting_a_div_around_all_fields_with_errors do
11
+ form_for record, options, &block
12
+ end
13
+ end
14
+
15
+ private
16
+
17
+ def prevent_action_view_putting_a_div_around_all_fields_with_errors(&block)
18
+ orig_field_error_proc = ::ActionView::Base.field_error_proc
19
+ begin
20
+ ::ActionView::Base.field_error_proc = SimpleBootstrapForm.method :noop_field_error_proc
21
+ yield
22
+ ensure
23
+ ::ActionView::Base.field_error_proc = orig_field_error_proc
24
+ end
25
+ end
26
+ end
27
+
28
+ def self.noop_field_error_proc(html_tag, instance)
29
+ html_tag
30
+ end
31
+ end
@@ -0,0 +1,32 @@
1
+ module SimpleBootstrapForm
2
+
3
+ class CssClassList < Array
4
+
5
+ def initialize(*classes)
6
+ replace normalize_array_or_string(classes)
7
+ end
8
+
9
+ def <<(classes)
10
+ replace self + normalize_array_or_string(classes)
11
+ uniq!
12
+ end
13
+
14
+ def to_s
15
+ join ' '
16
+ end
17
+
18
+ private
19
+
20
+ def normalize_array_or_string(classes)
21
+ if classes.is_a?(String)
22
+ classes.split ' '
23
+ elsif classes.is_a?(Array)
24
+ classes.flatten.join(' ').split(' ')
25
+ elsif classes.nil?
26
+ []
27
+ else
28
+ raise 'CssClassList takes an Array or String'
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,103 @@
1
+ module SimpleBootstrapForm
2
+ module Fields
3
+ class BaseField
4
+
5
+ class << self
6
+ attr_accessor :type
7
+ end
8
+
9
+ def initialize(form_builder, template, name, options)
10
+ @form_builder = form_builder
11
+ @template = template
12
+ @name = name
13
+ @options = options.dup
14
+ end
15
+
16
+ def to_s
17
+ @template.content_tag :div, group_options do
18
+ field_label +
19
+ input_tag +
20
+ errors_block
21
+ end
22
+ end
23
+
24
+ private
25
+
26
+ def group_options
27
+ css_classes = CssClassList.new 'form-group', group_name
28
+ css_classes << 'has-error' if has_error?
29
+ { class: css_classes }
30
+ end
31
+
32
+ def group_name # added as a class on form group to make it more testable
33
+ "#{@form_builder.object_name.to_s.underscore}_#{@name}_group"
34
+ end
35
+
36
+ def field_label
37
+ @form_builder.label @name, label_text, label_options
38
+ end
39
+
40
+ def label_text
41
+ text = @options[:label] || @name.to_s.humanize.capitalize
42
+ required_asterisk + text
43
+ end
44
+
45
+ def required_asterisk
46
+ if required?
47
+ @template.content_tag(:abbr, '*', title: 'required') + ' '
48
+ else
49
+ ''
50
+ end.html_safe
51
+ end
52
+
53
+ def label_options
54
+ css_classes = CssClassList.new 'control-label col-sm-3'
55
+ { class: css_classes }
56
+ end
57
+
58
+ def input_tag
59
+ @template.content_tag(:div, class: 'col-sm-6') do
60
+ @form_builder.text_field @name, input_options
61
+ end
62
+ end
63
+
64
+ def input_options
65
+ @options.merge! class: 'form-control',
66
+ placeholder: placeholder,
67
+ type: self.class.type
68
+ @options.merge! required: 'required' if required?
69
+ @options
70
+ end
71
+
72
+ def placeholder
73
+ @options[:placeholder] || @name.to_s.humanize
74
+ end
75
+
76
+ def errors_block
77
+ return '' unless errors.any?
78
+ @template.content_tag :span, errors.join(', '),
79
+ class: 'help-block col-sm-3'
80
+ end
81
+
82
+ def model
83
+ @form_builder.object
84
+ end
85
+
86
+ def errors
87
+ return [] unless model
88
+ @cached_errors ||= model.errors[@name.to_sym]
89
+ end
90
+
91
+ def required?
92
+ return false unless model
93
+ model.class.validators_on(@name).any? do |validator|
94
+ validator.kind_of? ActiveModel::Validations::PresenceValidator
95
+ end
96
+ end
97
+
98
+ def has_error?
99
+ errors.any?
100
+ end
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,14 @@
1
+ module SimpleBootstrapForm
2
+ module Fields
3
+ class BooleanField < BaseField
4
+
5
+ self.type = 'checkbox'
6
+
7
+ def input_tag
8
+ @template.content_tag(:div, class: 'col-sm-6') do
9
+ @form_builder.check_box @name
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,53 @@
1
+ module SimpleBootstrapForm
2
+ module Fields
3
+ class DatetimeField < BaseField
4
+
5
+ self.type = 'datetime'
6
+
7
+ def input_tag
8
+ @template.content_tag(:div, class: 'col-sm-6') do
9
+ @template.content_tag :div, class: 'input-group' do
10
+ @form_builder.text_field(@name, input_options) +
11
+ calendar_icon
12
+ end
13
+ end
14
+ end
15
+
16
+ private
17
+
18
+ def calendar_icon
19
+ @template.content_tag(:div, class: 'input-group-addon') do
20
+ @template.content_tag(:span, '',
21
+ class: 'glyphicon glyphicon-calendar',
22
+ data: { 'activate-datepicker' => "##{tag_id}" }
23
+ )
24
+ end
25
+ end
26
+
27
+ def input_options
28
+ super
29
+ @options.merge! value: value_suitable_for_use_by_jquery_datetimepicker
30
+ @options
31
+ end
32
+
33
+ def value_suitable_for_use_by_jquery_datetimepicker
34
+ @form_builder.object.send(@name).try(:strftime, '%Y/%m/%d %H:%M')
35
+ end
36
+
37
+ # Adapted from module ActionView::Helpers::Tags::Base
38
+ def tag_id
39
+ "#{sanitized_object_name}_#{sanitized_method_name}"
40
+ end
41
+
42
+ # Adapted from module ActionView::Helpers::Tags::Base
43
+ def sanitized_object_name
44
+ @form_builder.object_name.gsub(/\]\[|[^-a-zA-Z0-9:.]/, "_").sub(/_$/, "")
45
+ end
46
+
47
+ # Adapted from module ActionView::Helpers::Tags::Base
48
+ def sanitized_method_name
49
+ @name.to_s.sub(/\?$/,"")
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,8 @@
1
+ module SimpleBootstrapForm
2
+ module Fields
3
+ class EmailField < BaseField
4
+
5
+ self.type = 'email'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module SimpleBootstrapForm
2
+ module Fields
3
+ class PasswordField < BaseField
4
+
5
+ self.type = 'password'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module SimpleBootstrapForm
2
+ module Fields
3
+ class TextField < BaseField
4
+
5
+ self.type = 'text'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,12 @@
1
+ module SimpleBootstrapForm
2
+ module Fields
3
+ class TextareaField < BaseField
4
+
5
+ def input_tag
6
+ @template.content_tag(:div, class: 'col-sm-6') do
7
+ @form_builder.text_area @name, input_options
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,51 @@
1
+ module SimpleBootstrapForm
2
+ class FormBuilder < ActionView::Helpers::FormBuilder
3
+
4
+ # Context inherited from ActionView::Helpers::FormBuilder:
5
+ #
6
+ # @template
7
+ # object
8
+
9
+ def input(name, options = {})
10
+ klass = map_object_attribute_to_field_class name, options
11
+ klass.new(self, @template, name, options).to_s
12
+ end
13
+
14
+ private
15
+
16
+ def map_object_attribute_to_field_class(attr, options)
17
+ prefix = field_class_prefix attr, options
18
+ "SimpleBootstrapForm::Fields::#{prefix}Field".constantize
19
+ end
20
+
21
+ def field_class_prefix(attr, options)
22
+ if options[:as]
23
+ options[:as].to_s.capitalize
24
+ else
25
+ derive_field_class_prefix attr
26
+ end
27
+ end
28
+
29
+ def derive_field_class_prefix(attr)
30
+ case attr_column_type(attr)
31
+ when :boolean; 'Boolean'
32
+ when :datetime; 'Datetime'
33
+ when :string; string_field_class_prefix_based_on_column_name(attr)
34
+ when :text ; 'Textarea'
35
+ else 'Text'
36
+ end
37
+ end
38
+
39
+ def attr_column_type(attr)
40
+ object.try(:column_for_attribute, attr).try(:type) || :string
41
+ end
42
+
43
+ def string_field_class_prefix_based_on_column_name(attr)
44
+ x = case
45
+ when attr.to_s =~ /email/i ; 'Email'
46
+ when attr.to_s =~ /password/i ; 'Password'
47
+ else 'Text'
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,3 @@
1
+ module SimpleBootstrapForm
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,13 @@
1
+ require 'simple_bootstrap_form'
2
+ require 'simple_bootstrap_form/css_class_list'
3
+ require 'simple_bootstrap_form/action_view_extensions'
4
+ require 'simple_bootstrap_form/form_builder'
5
+ require 'simple_bootstrap_form/fields/base_field'
6
+ require 'simple_bootstrap_form/fields/boolean_field'
7
+ require 'simple_bootstrap_form/fields/datetime_field'
8
+ require 'simple_bootstrap_form/fields/email_field'
9
+ require 'simple_bootstrap_form/fields/password_field'
10
+ require 'simple_bootstrap_form/fields/text_field'
11
+ require 'simple_bootstrap_form/fields/textarea_field'
12
+
13
+ ActionView::Base.send :include, SimpleBootstrapForm::ActionViewExtensions
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'simple_bootstrap_form/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "simple_bootstrap_form"
8
+ spec.version = SimpleBootstrapForm::VERSION
9
+ spec.authors = ["Sam Pierson"]
10
+ spec.email = ["gems@sampierson.com"]
11
+ spec.summary = %q{Bootstrap 3 Form Helper}
12
+ spec.description = %q{A form helper with a 'Simple Form'-like interface, that supports Bootstrap 3}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.5"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec-rails", ">= 3.0.0.beta1"
24
+ spec.add_development_dependency "sqlite3"
25
+ spec.add_development_dependency "capybara" # for has_selector? method
26
+ spec.add_runtime_dependency "rails", ">= 4"
27
+ end
data/spec/dummy/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -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>.
@@ -0,0 +1,6 @@
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
+ Dummy::Application.load_tasks
File without changes
@@ -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 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
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,13 @@
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 vendor/assets/stylesheets of plugins, if any, 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 top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
File without changes
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
File without changes
File without changes
@@ -0,0 +1,6 @@
1
+ class Account < ActiveRecord::Base
2
+ #has_secure_password
3
+
4
+ validates :email, :first_name, :last_name, presence: true
5
+ validates :email, uniqueness: true
6
+ end
@@ -0,0 +1,2 @@
1
+ class Article < ActiveRecord::Base
2
+ end
File without changes
@@ -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>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run