├── log
└── .keep
├── lib
├── assets
│ └── .keep
├── tasks
│ └── .keep
└── templates
│ └── haml
│ └── scaffold
│ └── _form.html.haml
├── .ruby-version
├── vendor
└── assets
│ ├── javascripts
│ └── .keep
│ └── stylesheets
│ └── .keep
├── config
├── locales
│ ├── en.yml
│ └── simple_form.en.yml
├── initializers
│ ├── cookies_serializer.rb
│ ├── filter_parameter_logging.rb
│ ├── session_store.rb
│ ├── wrap_parameters.rb
│ ├── simple_form_bootstrap.rb
│ └── simple_form.rb
├── environment.rb
├── routes.rb
├── boot.rb
├── application.rb
├── database.yml
├── secrets.yml
└── environments
│ ├── development.rb
│ ├── test.rb
│ └── production.rb
├── app
├── models
│ └── task.rb
├── views
│ ├── tasks
│ │ ├── destroy.js.erb
│ │ ├── _datetimepicker.js
│ │ ├── create.js.erb
│ │ ├── update.js.erb
│ │ ├── new.js.erb
│ │ ├── edit.js.erb
│ │ ├── _form.html.erb
│ │ ├── _task.html.erb
│ │ └── index.html.erb
│ └── layouts
│ │ ├── _header.html.erb
│ │ └── application.html.erb
├── controllers
│ ├── application_controller.rb
│ └── tasks_controller.rb
├── assets
│ ├── javascripts
│ │ └── application.js
│ └── stylesheets
│ │ ├── application.css.scss
│ │ └── layout.css.scss
└── inputs
│ └── datetimepicker_input.rb
├── config.ru
├── Rakefile
├── README.md
├── bin
├── bundle
├── rake
├── rails
└── spring
├── .gitignore
├── db
├── migrate
│ └── 20140620130316_create_tasks.rb
├── seeds.rb
└── schema.rb
├── Gemfile
└── Gemfile.lock
/log/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/assets/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/tasks/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.ruby-version:
--------------------------------------------------------------------------------
1 | 2.1.0
2 |
--------------------------------------------------------------------------------
/vendor/assets/javascripts/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/vendor/assets/stylesheets/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/config/locales/en.yml:
--------------------------------------------------------------------------------
1 | en:
2 | hello: "Hello world"
3 |
--------------------------------------------------------------------------------
/app/models/task.rb:
--------------------------------------------------------------------------------
1 | class Task < ActiveRecord::Base; end
2 |
--------------------------------------------------------------------------------
/app/views/tasks/destroy.js.erb:
--------------------------------------------------------------------------------
1 | $('#tasks').html("<%= escape_javascript(render @tasks) %>");
2 |
--------------------------------------------------------------------------------
/config.ru:
--------------------------------------------------------------------------------
1 | require ::File.expand_path('../config/environment', __FILE__)
2 | run Rails.application
3 |
--------------------------------------------------------------------------------
/Rakefile:
--------------------------------------------------------------------------------
1 | require File.expand_path('../config/application', __FILE__)
2 |
3 | Rails.application.load_tasks
4 |
--------------------------------------------------------------------------------
/config/initializers/cookies_serializer.rb:
--------------------------------------------------------------------------------
1 | Rails.application.config.action_dispatch.cookies_serializer = :json
2 |
--------------------------------------------------------------------------------
/config/initializers/filter_parameter_logging.rb:
--------------------------------------------------------------------------------
1 | Rails.application.config.filter_parameters += [:password]
2 |
--------------------------------------------------------------------------------
/config/environment.rb:
--------------------------------------------------------------------------------
1 | require File.expand_path('../application', __FILE__)
2 |
3 | Rails.application.initialize!
4 |
--------------------------------------------------------------------------------
/config/initializers/session_store.rb:
--------------------------------------------------------------------------------
1 | Rails.application.config.session_store :cookie_store, key: '_rai-jax_session'
2 |
--------------------------------------------------------------------------------
/config/routes.rb:
--------------------------------------------------------------------------------
1 | Rails.application.routes.draw do
2 | root 'tasks#index'
3 |
4 | resources :tasks
5 | end
6 |
--------------------------------------------------------------------------------
/app/views/layouts/_header.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
Rai-jax Task List
3 |
4 |
--------------------------------------------------------------------------------
/app/views/tasks/_datetimepicker.js:
--------------------------------------------------------------------------------
1 | $(document).ready(function() {
2 | $('#datetimepicker1').datetimepicker();
3 | });
4 |
--------------------------------------------------------------------------------
/app/views/tasks/create.js.erb:
--------------------------------------------------------------------------------
1 | $('#tasks').html("<%= escape_javascript(render @tasks) %>");
2 | $('#task-form').slideUp(350);
3 |
--------------------------------------------------------------------------------
/app/views/tasks/update.js.erb:
--------------------------------------------------------------------------------
1 | $('#tasks').html("<%= escape_javascript(render @tasks) %>");
2 | $('#task-form').slideUp(350);
3 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Rai-jax Task List
2 |
3 | ## About
4 |
5 | A dynamic single-page Task list app utilizing ajax rails conventions.
6 |
--------------------------------------------------------------------------------
/app/controllers/application_controller.rb:
--------------------------------------------------------------------------------
1 | class ApplicationController < ActionController::Base
2 | protect_from_forgery with: :exception
3 | end
4 |
--------------------------------------------------------------------------------
/bin/bundle:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3 | load Gem.bin_path('bundler', 'bundle')
4 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.swp
2 | *~
3 |
4 | /.bundle
5 | /log/*.log
6 | /tmp
7 | /public
8 | .secret
9 |
10 | /db/*.sqlite3
11 | /db/*.sqlite3-journal
12 |
--------------------------------------------------------------------------------
/app/views/tasks/new.js.erb:
--------------------------------------------------------------------------------
1 | $('#task-form').html("<%= j (render 'form') %>");
2 | $('#task-form').slideDown(350);
3 |
4 | <%= render 'datetimepicker' %>
5 |
--------------------------------------------------------------------------------
/config/boot.rb:
--------------------------------------------------------------------------------
1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
2 |
3 | require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
4 |
--------------------------------------------------------------------------------
/config/initializers/wrap_parameters.rb:
--------------------------------------------------------------------------------
1 | ActiveSupport.on_load(:action_controller) do
2 | wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
3 | end
4 |
--------------------------------------------------------------------------------
/app/views/tasks/edit.js.erb:
--------------------------------------------------------------------------------
1 | $('#task-form').html("<%= escape_javascript(render 'form') %>");
2 | $('#task-form').slideDown(350);
3 |
4 | <%= render 'datetimepicker' %>
5 |
--------------------------------------------------------------------------------
/app/assets/javascripts/application.js:
--------------------------------------------------------------------------------
1 | //= require jquery
2 | //= require jquery_ujs
3 | //= require turbolinks
4 | //= require bootstrap
5 | //= require moment
6 | //= require bootstrap-datetimepicker
7 |
--------------------------------------------------------------------------------
/bin/rake:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | begin
3 | load File.expand_path("../spring", __FILE__)
4 | rescue LoadError
5 | end
6 | require_relative '../config/boot'
7 | require 'rake'
8 | Rake.application.run
9 |
--------------------------------------------------------------------------------
/config/application.rb:
--------------------------------------------------------------------------------
1 | require File.expand_path('../boot', __FILE__)
2 |
3 | require 'rails/all'
4 |
5 | Bundler.require(*Rails.groups)
6 |
7 | module RaiJax
8 | class Application < Rails::Application; end
9 | end
10 |
--------------------------------------------------------------------------------
/app/views/tasks/_form.html.erb:
--------------------------------------------------------------------------------
1 | <%= simple_form_for @task, remote: true do |f| %>
2 | <%= f.input :description, as: :text %>
3 | <%= f.input :deadline, as: :datetimepicker %>
4 | <%= f.button :submit %>
5 | <% end %>
6 |
--------------------------------------------------------------------------------
/bin/rails:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | begin
3 | load File.expand_path("../spring", __FILE__)
4 | rescue LoadError
5 | end
6 | APP_PATH = File.expand_path('../../config/application', __FILE__)
7 | require_relative '../config/boot'
8 | require 'rails/commands'
9 |
--------------------------------------------------------------------------------
/config/locales/simple_form.en.yml:
--------------------------------------------------------------------------------
1 | en:
2 | simple_form:
3 | "yes": 'Yes'
4 | "no": 'No'
5 | required:
6 | text: 'required'
7 | mark: '*'
8 |
9 | error_notification:
10 | default_message: "Please review the problems below:"
11 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/application.css.scss:
--------------------------------------------------------------------------------
1 | /*
2 | *= require_self
3 | *= require layout
4 | */
5 |
6 | $btn-default-bg: #9B111E;
7 | $btn-default-color: white;
8 | $btn-default-border: black;
9 |
10 | @import 'bootstrap';
11 | @import 'bootstrap-datetimepicker';
12 |
--------------------------------------------------------------------------------
/db/migrate/20140620130316_create_tasks.rb:
--------------------------------------------------------------------------------
1 | class CreateTasks < ActiveRecord::Migration
2 | def change
3 | create_table :tasks do |t|
4 | t.timestamps null: false
5 |
6 | t.string :description, null: false
7 | t.datetime :deadline
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/lib/templates/haml/scaffold/_form.html.haml:
--------------------------------------------------------------------------------
1 | = simple_form_for(@<%= singular_table_name %>) do |f|
2 | = f.error_notification
3 |
4 | .form-inputs
5 | <%- attributes.each do |attribute| -%>
6 | = f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %>
7 | <%- end -%>
8 |
9 | .form-actions
10 | = f.button :submit
11 |
--------------------------------------------------------------------------------
/config/database.yml:
--------------------------------------------------------------------------------
1 | development:
2 | adapter: sqlite3
3 | database: db/development.sqlite3
4 | pool: 5
5 | timeout: 5000
6 |
7 | test:
8 | adapter: sqlite3
9 | database: db/test.sqlite3
10 | pool: 5
11 | timeout: 5000
12 |
13 | production:
14 | adapter: sqlite3
15 | database: db/production.sqlite3
16 | pool: 5
17 | timeout: 5000
18 |
--------------------------------------------------------------------------------
/db/seeds.rb:
--------------------------------------------------------------------------------
1 | Task.delete_all
2 |
3 | Task.create!(description: 'This is a task description',
4 | deadline: '2014-07-01 01:00:00')
5 |
6 | Task.create!(description: 'This is another task description',
7 | deadline: '2014-07-02 01:00:00')
8 |
9 | Task.create!(description: 'Yet another task description',
10 | deadline: '2014-07-03 01:00:00')
11 |
--------------------------------------------------------------------------------
/config/secrets.yml:
--------------------------------------------------------------------------------
1 | development:
2 | secret_key_base: 36cdcfee41d931aeacab9e11a060e8b01e35667025aa0c5f418c71a48918a7fd5530703a163e4605242fc5a0551b78357bc07e25c1ae1fb78829dae8d92259fd
3 |
4 | test:
5 | secret_key_base: 7ee8779f8d5896f230bbdfa759c5ef775cca59e2f37c82fa3c819fd08049508e14e684da3a40687ecf7ec93354800bcc43cb71400fda10f12fdfb532db80355e
6 |
7 | production:
8 | secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
9 |
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source 'https://rubygems.org'
2 | ruby '2.1.0'
3 |
4 | gem 'rails', '4.1.1'
5 | gem 'sqlite3'
6 |
7 | gem 'sass-rails', '~> 4.0.3'
8 | gem 'uglifier', '>= 1.3.0'
9 | gem 'coffee-rails', '~> 4.0.0'
10 | gem 'jquery-rails', '~> 3.1.0'
11 | gem 'turbolinks', '~> 2.2.2'
12 | gem 'jbuilder', '~> 2.0'
13 | gem 'bootstrap-sass', '~> 3.1.1.1'
14 | gem 'momentjs-rails', '~> 2.5.0'
15 | gem 'bootstrap3-datetimepicker-rails', '~> 3.0.0.1'
16 | gem 'simple_form', '~> 3.1.0.rc1'
17 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/layout.css.scss:
--------------------------------------------------------------------------------
1 | html {
2 | position: relative;
3 | min-height: 100%;
4 | }
5 |
6 | body { margin-bottom: 60px; }
7 |
8 | #header {
9 | height: 70px;
10 | min-width: 100%;
11 | background-color: black;
12 | color: #9B111E;
13 | }
14 |
15 | .content { padding: 50px; }
16 |
17 | #tasks, .deadline { padding-left: 15px; }
18 |
19 | .edit {
20 | float: right;
21 | padding-right: 10px;
22 | }
23 |
24 | #task-form { padding-bottom: 15px; }
25 |
--------------------------------------------------------------------------------
/config/environments/development.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | config.cache_classes = false
3 | config.eager_load = false
4 | config.consider_all_requests_local = true
5 | config.action_controller.perform_caching = false
6 | config.action_mailer.raise_delivery_errors = false
7 | config.active_support.deprecation = :log
8 | config.active_record.migration_error = :page_load
9 | config.assets.debug = true
10 | config.assets.raise_runtime_errors = true
11 | end
12 |
--------------------------------------------------------------------------------
/config/environments/test.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | config.cache_classes = true
3 | config.eager_load = false
4 | config.serve_static_assets = true
5 | config.static_cache_control = 'public, max-age=3600'
6 | config.consider_all_requests_local = true
7 | config.action_controller.perform_caching = false
8 | config.action_dispatch.show_exceptions = false
9 | config.action_controller.allow_forgery_protection = false
10 | config.action_mailer.delivery_method = :test
11 | config.active_support.deprecation = :stderr
12 | end
13 |
--------------------------------------------------------------------------------
/app/views/tasks/_task.html.erb:
--------------------------------------------------------------------------------
1 |
2 | <%= task.description %>
3 |
4 | <%= task.deadline %>
5 |
6 |
7 | <%= link_to edit_task_path(task), remote: true do %>
8 |
9 | <% end %>
10 |
11 |
12 | <%= link_to task, remote: true, method: :delete,
13 | data: { confirm: 'Are you sure?' } do %>
14 |
15 | <% end %>
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/views/tasks/index.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
Tasks
4 |
5 |
6 |
7 | <%= link_to new_task_path, remote: true do %>
8 |
9 | <% end %>
10 |
11 |
12 |
13 |
16 |
17 |
18 |
<%= render @tasks %>
19 |
20 |
--------------------------------------------------------------------------------
/bin/spring:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | # This file loads spring without using Bundler, in order to be fast
4 | # It gets overwritten when you run the `spring binstub` command
5 |
6 | unless defined?(Spring)
7 | require "rubygems"
8 | require "bundler"
9 |
10 | if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ spring \((.*?)\)$.*?^$/m)
11 | ENV["GEM_PATH"] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR)
12 | ENV["GEM_HOME"] = ""
13 | Gem.paths = ENV
14 |
15 | gem "spring", match[1]
16 | require "spring/binstub"
17 | end
18 | end
19 |
--------------------------------------------------------------------------------
/app/views/layouts/application.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Rai-jax Task List
6 | <%= stylesheet_link_tag 'application', media: 'all',
7 | 'data-turbolinks-track' => true %>
8 | <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
9 | <%= csrf_meta_tags %>
10 |
11 |
12 |
13 |
14 |
15 |
<%= yield %>
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/config/environments/production.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | config.cache_classes = true
3 | config.eager_load = true
4 | config.consider_all_requests_local = false
5 | config.action_controller.perform_caching = true
6 | config.serve_static_assets = false
7 | config.assets.js_compressor = :uglifier
8 | config.assets.compile = false
9 | config.assets.digest = true
10 | config.assets.version = '1.0'
11 | config.log_level = :info
12 | config.i18n.fallbacks = true
13 | config.active_support.deprecation = :notify
14 | config.log_formatter = ::Logger::Formatter.new
15 | config.active_record.dump_schema_after_migration = false
16 | end
17 |
--------------------------------------------------------------------------------
/app/controllers/tasks_controller.rb:
--------------------------------------------------------------------------------
1 | class TasksController < ApplicationController
2 | before_action :all_tasks, only: [:index, :create, :update, :destroy]
3 | before_action :set_tasks, only: [:edit, :update, :destroy]
4 | respond_to :html, :js
5 |
6 | def new
7 | @task = Task.new
8 | end
9 |
10 | def create
11 | @task = Task.create(task_params)
12 | end
13 |
14 | def update
15 | @task.update_attributes(task_params)
16 | end
17 |
18 | def destroy
19 | @task.destroy
20 | end
21 |
22 | private
23 |
24 | def all_tasks
25 | @tasks = Task.all
26 | end
27 |
28 | def set_tasks
29 | @task = Task.find(params[:id])
30 | end
31 |
32 | def task_params
33 | params.require(:task).permit(:description, :deadline)
34 | end
35 | end
36 |
--------------------------------------------------------------------------------
/app/inputs/datetimepicker_input.rb:
--------------------------------------------------------------------------------
1 | class DatetimepickerInput < SimpleForm::Inputs::StringInput
2 |
3 | def input(wrapper_options)
4 | value = object.send(attribute_name) if object.respond_to? attribute_name
5 | input_html_options[:type] = 'text'
6 |
7 | if value.present?
8 | input_html_options[:value] ||= value.strftime('%B %d %Y %l:%M %p')
9 | end
10 |
11 | input_html_options[:data] ||= {}
12 | input_html_options[:data].merge!({ class: 'form-control' })
13 |
14 | template.content_tag :div, class: 'input-group date', id: 'datetimepicker1',
15 | 'data-date-format' => 'lll' do
16 | input = super
17 | input += template.content_tag :span, class: 'input-group-addon' do
18 | template.content_tag :span, '', class: 'glyphicon glyphicon-calendar'
19 | end
20 | input
21 | end
22 | end
23 | end
24 |
--------------------------------------------------------------------------------
/db/schema.rb:
--------------------------------------------------------------------------------
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: 20140620130316) do
15 |
16 | create_table "tasks", force: true do |t|
17 | t.datetime "created_at", null: false
18 | t.datetime "updated_at", null: false
19 | t.string "description", null: false
20 | t.datetime "deadline"
21 | end
22 |
23 | end
24 |
--------------------------------------------------------------------------------
/Gemfile.lock:
--------------------------------------------------------------------------------
1 | GEM
2 | remote: https://rubygems.org/
3 | specs:
4 | actionmailer (4.1.1)
5 | actionpack (= 4.1.1)
6 | actionview (= 4.1.1)
7 | mail (~> 2.5.4)
8 | actionpack (4.1.1)
9 | actionview (= 4.1.1)
10 | activesupport (= 4.1.1)
11 | rack (~> 1.5.2)
12 | rack-test (~> 0.6.2)
13 | actionview (4.1.1)
14 | activesupport (= 4.1.1)
15 | builder (~> 3.1)
16 | erubis (~> 2.7.0)
17 | activemodel (4.1.1)
18 | activesupport (= 4.1.1)
19 | builder (~> 3.1)
20 | activerecord (4.1.1)
21 | activemodel (= 4.1.1)
22 | activesupport (= 4.1.1)
23 | arel (~> 5.0.0)
24 | activesupport (4.1.1)
25 | i18n (~> 0.6, >= 0.6.9)
26 | json (~> 1.7, >= 1.7.7)
27 | minitest (~> 5.1)
28 | thread_safe (~> 0.1)
29 | tzinfo (~> 1.1)
30 | arel (5.0.1.20140414130214)
31 | bootstrap-sass (3.1.1.1)
32 | sass (~> 3.2)
33 | bootstrap3-datetimepicker-rails (3.0.0.1)
34 | momentjs-rails (~> 2.5.0)
35 | builder (3.2.2)
36 | coffee-rails (4.0.1)
37 | coffee-script (>= 2.2.0)
38 | railties (>= 4.0.0, < 5.0)
39 | coffee-script (2.2.0)
40 | coffee-script-source
41 | execjs
42 | coffee-script-source (1.7.0)
43 | erubis (2.7.0)
44 | execjs (2.2.0)
45 | hike (1.2.3)
46 | i18n (0.6.9)
47 | jbuilder (2.1.1)
48 | activesupport (>= 3.0.0, < 5)
49 | multi_json (~> 1.2)
50 | jquery-rails (3.1.0)
51 | railties (>= 3.0, < 5.0)
52 | thor (>= 0.14, < 2.0)
53 | json (1.8.1)
54 | mail (2.5.4)
55 | mime-types (~> 1.16)
56 | treetop (~> 1.4.8)
57 | mime-types (1.25.1)
58 | minitest (5.3.5)
59 | momentjs-rails (2.5.1)
60 | railties (>= 3.1)
61 | multi_json (1.10.1)
62 | polyglot (0.3.5)
63 | rack (1.5.2)
64 | rack-test (0.6.2)
65 | rack (>= 1.0)
66 | rails (4.1.1)
67 | actionmailer (= 4.1.1)
68 | actionpack (= 4.1.1)
69 | actionview (= 4.1.1)
70 | activemodel (= 4.1.1)
71 | activerecord (= 4.1.1)
72 | activesupport (= 4.1.1)
73 | bundler (>= 1.3.0, < 2.0)
74 | railties (= 4.1.1)
75 | sprockets-rails (~> 2.0)
76 | railties (4.1.1)
77 | actionpack (= 4.1.1)
78 | activesupport (= 4.1.1)
79 | rake (>= 0.8.7)
80 | thor (>= 0.18.1, < 2.0)
81 | rake (10.3.2)
82 | sass (3.2.19)
83 | sass-rails (4.0.3)
84 | railties (>= 4.0.0, < 5.0)
85 | sass (~> 3.2.0)
86 | sprockets (~> 2.8, <= 2.11.0)
87 | sprockets-rails (~> 2.0)
88 | simple_form (3.1.0.rc1)
89 | actionpack (~> 4.0)
90 | activemodel (~> 4.0)
91 | sprockets (2.11.0)
92 | hike (~> 1.2)
93 | multi_json (~> 1.0)
94 | rack (~> 1.0)
95 | tilt (~> 1.1, != 1.3.0)
96 | sprockets-rails (2.1.3)
97 | actionpack (>= 3.0)
98 | activesupport (>= 3.0)
99 | sprockets (~> 2.8)
100 | sqlite3 (1.3.9)
101 | thor (0.19.1)
102 | thread_safe (0.3.4)
103 | tilt (1.4.1)
104 | treetop (1.4.15)
105 | polyglot
106 | polyglot (>= 0.3.1)
107 | turbolinks (2.2.2)
108 | coffee-rails
109 | tzinfo (1.2.1)
110 | thread_safe (~> 0.1)
111 | uglifier (2.5.1)
112 | execjs (>= 0.3.0)
113 | json (>= 1.8.0)
114 |
115 | PLATFORMS
116 | ruby
117 |
118 | DEPENDENCIES
119 | bootstrap-sass (~> 3.1.1.1)
120 | bootstrap3-datetimepicker-rails (~> 3.0.0.1)
121 | coffee-rails (~> 4.0.0)
122 | jbuilder (~> 2.0)
123 | jquery-rails (~> 3.1.0)
124 | momentjs-rails (~> 2.5.0)
125 | rails (= 4.1.1)
126 | sass-rails (~> 4.0.3)
127 | simple_form (~> 3.1.0.rc1)
128 | sqlite3
129 | turbolinks (~> 2.2.2)
130 | uglifier (>= 1.3.0)
131 |
--------------------------------------------------------------------------------
/config/initializers/simple_form_bootstrap.rb:
--------------------------------------------------------------------------------
1 | # Use this setup block to configure all options available in SimpleForm.
2 | SimpleForm.setup do |config|
3 | config.button_class = 'btn btn-default'
4 | config.boolean_label_class = nil
5 |
6 | config.wrappers :vertical_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
7 | b.use :html5
8 | b.use :placeholder
9 | b.use :label, class: 'control-label'
10 |
11 | b.wrapper tag: 'div' do |ba|
12 | ba.use :input, class: 'form-control'
13 | ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
14 | ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
15 | end
16 | end
17 |
18 | config.wrappers :vertical_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
19 | b.use :html5
20 | b.use :placeholder
21 | b.use :label, class: 'control-label'
22 |
23 | b.wrapper tag: 'div' do |ba|
24 | ba.use :input
25 | ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
26 | ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
27 | end
28 | end
29 |
30 | config.wrappers :vertical_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
31 | b.use :html5
32 | b.use :placeholder
33 |
34 | b.wrapper tag: 'div', class: 'checkbox' do |ba|
35 | ba.use :label_input
36 | end
37 |
38 | b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
39 | b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
40 | end
41 |
42 | config.wrappers :vertical_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
43 | b.use :html5
44 | b.use :placeholder
45 | b.use :label_input
46 | b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
47 | b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
48 | end
49 |
50 | config.wrappers :horizontal_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
51 | b.use :html5
52 | b.use :placeholder
53 | b.use :label, class: 'col-sm-3 control-label'
54 |
55 | b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
56 | ba.use :input, class: 'form-control'
57 | ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
58 | ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
59 | end
60 | end
61 |
62 | config.wrappers :horizontal_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
63 | b.use :html5
64 | b.use :placeholder
65 | b.use :label, class: 'col-sm-3 control-label'
66 |
67 | b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
68 | ba.use :input
69 | ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
70 | ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
71 | end
72 | end
73 |
74 | config.wrappers :horizontal_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
75 | b.use :html5
76 | b.use :placeholder
77 |
78 | b.wrapper tag: 'div', class: 'col-sm-offset-3 col-sm-9' do |wr|
79 | wr.wrapper tag: 'div', class: 'checkbox' do |ba|
80 | ba.use :label_input, class: 'col-sm-9'
81 | end
82 |
83 | wr.use :error, wrap_with: { tag: 'span', class: 'help-block' }
84 | wr.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
85 | end
86 | end
87 |
88 | config.wrappers :horizontal_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
89 | b.use :html5
90 | b.use :placeholder
91 |
92 | b.use :label, class: 'col-sm-3 control-label'
93 |
94 | b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
95 | ba.use :input
96 | ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
97 | ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
98 | end
99 | end
100 |
101 | # Wrappers for forms and inputs using the Bootstrap toolkit.
102 | # Check the Bootstrap docs (http://getbootstrap.com)
103 | # to learn about the different styles for forms and inputs,
104 | # buttons and other elements.
105 | config.default_wrapper = :vertical_form
106 | end
107 |
--------------------------------------------------------------------------------
/config/initializers/simple_form.rb:
--------------------------------------------------------------------------------
1 | # Use this setup block to configure all options available in SimpleForm.
2 | SimpleForm.setup do |config|
3 | # Wrappers are used by the form builder to generate a
4 | # complete input. You can remove any component from the
5 | # wrapper, change the order or even add your own to the
6 | # stack. The options given below are used to wrap the
7 | # whole input.
8 | config.wrappers :default, class: :input,
9 | hint_class: :field_with_hint, error_class: :field_with_errors do |b|
10 | ## Extensions enabled by default
11 | # Any of these extensions can be disabled for a
12 | # given input by passing: `f.input EXTENSION_NAME => false`.
13 | # You can make any of these extensions optional by
14 | # renaming `b.use` to `b.optional`.
15 |
16 | # Determines whether to use HTML5 (:email, :url, ...)
17 | # and required attributes
18 | b.use :html5
19 |
20 | # Calculates placeholders automatically from I18n
21 | # You can also pass a string as f.input placeholder: "Placeholder"
22 | b.use :placeholder
23 |
24 | ## Optional extensions
25 | # They are disabled unless you pass `f.input EXTENSION_NAME => :lookup`
26 | # to the input. If so, they will retrieve the values from the model
27 | # if any exists. If you want to enable the lookup for any of those
28 | # extensions by default, you can change `b.optional` to `b.use`.
29 |
30 | # Calculates maxlength from length validations for string inputs
31 | b.optional :maxlength
32 |
33 | # Calculates pattern from format validations for string inputs
34 | b.optional :pattern
35 |
36 | # Calculates min and max from length validations for numeric inputs
37 | b.optional :min_max
38 |
39 | # Calculates readonly automatically from readonly attributes
40 | b.optional :readonly
41 |
42 | ## Inputs
43 | b.use :label_input
44 | b.use :hint, wrap_with: { tag: :span, class: :hint }
45 | b.use :error, wrap_with: { tag: :span, class: :error }
46 |
47 | ## full_messages_for
48 | # If you want to display the full error message for the attribute, you can
49 | # use the component :full_error, like:
50 | #
51 | # b.use :full_error, wrap_with: { tag: :span, class: :error }
52 | end
53 |
54 | # The default wrapper to be used by the FormBuilder.
55 | config.default_wrapper = :default
56 |
57 | # Define the way to render check boxes / radio buttons with labels.
58 | # Defaults to :nested for bootstrap config.
59 | # inline: input + label
60 | # nested: label > input
61 | config.boolean_style = :nested
62 |
63 | # Default class for buttons
64 | config.button_class = 'btn'
65 |
66 | # Method used to tidy up errors. Specify any Rails Array method.
67 | # :first lists the first message for each field.
68 | # Use :to_sentence to list all errors for each field.
69 | # config.error_method = :first
70 |
71 | # Default tag used for error notification helper.
72 | config.error_notification_tag = :div
73 |
74 | # CSS class to add for error notification helper.
75 | config.error_notification_class = 'error_notification'
76 |
77 | # ID to add for error notification helper.
78 | # config.error_notification_id = nil
79 |
80 | # Series of attempts to detect a default label method for collection.
81 | # config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
82 |
83 | # Series of attempts to detect a default value method for collection.
84 | # config.collection_value_methods = [ :id, :to_s ]
85 |
86 | # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
87 | # config.collection_wrapper_tag = nil
88 |
89 | # You can define the class to use on all collection wrappers. Defaulting to none.
90 | # config.collection_wrapper_class = nil
91 |
92 | # You can wrap each item in a collection of radio/check boxes with a tag,
93 | # defaulting to :span. Please note that when using :boolean_style = :nested,
94 | # SimpleForm will force this option to be a label.
95 | # config.item_wrapper_tag = :span
96 |
97 | # You can define a class to use in all item wrappers. Defaulting to none.
98 | # config.item_wrapper_class = nil
99 |
100 | # How the label text should be generated altogether with the required text.
101 | # config.label_text = lambda { |label, required, explicit_label| "#{required} #{label}" }
102 |
103 | # You can define the class to use on all labels. Default is nil.
104 | # config.label_class = nil
105 |
106 | # You can define the class to use on all forms. Default is simple_form.
107 | # config.form_class = :simple_form
108 |
109 | # You can define which elements should obtain additional classes
110 | # config.generate_additional_classes_for = [:wrapper, :label, :input]
111 |
112 | # Whether attributes are required by default (or not). Default is true.
113 | # config.required_by_default = true
114 |
115 | # Tell browsers whether to use the native HTML5 validations (novalidate form option).
116 | # These validations are enabled in SimpleForm's internal config but disabled by default
117 | # in this configuration, which is recommended due to some quirks from different browsers.
118 | # To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations,
119 | # change this configuration to true.
120 | config.browser_validations = false
121 |
122 | # Collection of methods to detect if a file type was given.
123 | # config.file_methods = [ :mounted_as, :file?, :public_filename ]
124 |
125 | # Custom mappings for input types. This should be a hash containing a regexp
126 | # to match as key, and the input type that will be used when the field name
127 | # matches the regexp as value.
128 | # config.input_mappings = { /count/ => :integer }
129 |
130 | # Custom wrappers for input types. This should be a hash containing an input
131 | # type as key and the wrapper that will be used for all inputs with specified type.
132 | # config.wrapper_mappings = { string: :prepend }
133 |
134 | # Default priority for time_zone inputs.
135 | # config.time_zone_priority = nil
136 |
137 | # Default priority for country inputs.
138 | # config.country_priority = nil
139 |
140 | # When false, do not use translations for labels.
141 | # config.translate_labels = true
142 |
143 | # Automatically discover new inputs in Rails' autoload path.
144 | # config.inputs_discovery = true
145 |
146 | # Cache SimpleForm inputs discovery
147 | # config.cache_discovery = !Rails.env.development?
148 |
149 | # Default class for inputs
150 | # config.input_class = nil
151 |
152 | # Define the default class of the input wrapper of the boolean input.
153 | config.boolean_label_class = 'checkbox'
154 |
155 | # Defines if the default input wrapper class should be included in radio
156 | # collection wrappers.
157 | # config.include_default_input_wrapper_class = true
158 |
159 | # Defines which i18n scope will be used in Simple Form.
160 | # config.i18n_scope = 'simple_form'
161 | end
162 |
--------------------------------------------------------------------------------