activemodel-form 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +17 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +71 -0
- data/Rakefile +16 -0
- data/activemodel-form.gemspec +25 -0
- data/example/.gitignore +15 -0
- data/example/Gemfile +13 -0
- data/example/README.md +9 -0
- data/example/app/controllers/application_controller.rb +3 -0
- data/example/app/controllers/forms_controller.rb +25 -0
- data/example/app/views/forms/new.html.erb +24 -0
- data/example/app/views/layouts/application.html.erb +13 -0
- data/example/config/application.rb +62 -0
- data/example/config/boot.rb +6 -0
- data/example/config/database.yml +11 -0
- data/example/config/environment.rb +5 -0
- data/example/config/environments/development.rb +37 -0
- data/example/config/environments/production.rb +67 -0
- data/example/config/environments/test.rb +37 -0
- data/example/config/initializers/backtrace_silencers.rb +7 -0
- data/example/config/initializers/formtastic.rb +90 -0
- data/example/config/initializers/inflections.rb +15 -0
- data/example/config/initializers/mime_types.rb +5 -0
- data/example/config/initializers/secret_token.rb +7 -0
- data/example/config/initializers/session_store.rb +8 -0
- data/example/config/initializers/simple_form.rb +138 -0
- data/example/config/initializers/wrap_parameters.rb +14 -0
- data/example/config/routes.rb +8 -0
- data/example/config.ru +4 -0
- data/example/public/404.html +26 -0
- data/example/public/422.html +26 -0
- data/example/public/500.html +25 -0
- data/example/public/favicon.ico +0 -0
- data/example/public/robots.txt +5 -0
- data/example/script/rails +6 -0
- data/lib/active_model/form/attributes.rb +107 -0
- data/lib/active_model/form/version.rb +5 -0
- data/lib/active_model/form.rb +85 -0
- data/lib/activemodel-form.rb +1 -0
- data/spec/boolean_attribute_form_spec.rb +24 -0
- data/spec/date_time_form_spec.rb +27 -0
- data/spec/integer_attribute_form_spec.rb +24 -0
- data/spec/model_name_spec.rb +17 -0
- data/spec/spec_helper.rb +6 -0
- metadata +165 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Martin Schürrer
|
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,71 @@
|
|
1
|
+
# ActiveModel::Form
|
2
|
+
|
3
|
+
ActiveModel lets you easily create objects that can be used in form helpers and even support round-tripping (assigning the submitted params again)
|
4
|
+
|
5
|
+
But ActiveModel doesn't support out of the box argument parsing, e.g. having a datetime attribute be a datetime attribute and a boolean attribute be a boolean attribute.
|
6
|
+
|
7
|
+
This fixes that.
|
8
|
+
|
9
|
+
ActiveModel::Form happened because the "tableless model" presented in
|
10
|
+
[RailsCast 219](http://railscasts.com/episodes/219-active-model) wasn't
|
11
|
+
as powerful as the "real deal" from [RailsCast 193](http://railscasts.com/episodes/193-tableless-model/).
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
gem 'activemodel-form'
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
In the controller:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
class FormsController < ApplicationController
|
25
|
+
class SearchForm < ActiveModel::Form
|
26
|
+
self.model_name = 'q' # => <input name="q[username]" ... /> etc.
|
27
|
+
attribute :username, :string
|
28
|
+
attribute :created_at, :date_time
|
29
|
+
attribute :locked, :boolean
|
30
|
+
|
31
|
+
validates_presence_of :username
|
32
|
+
validates_presence_of :created_at
|
33
|
+
end
|
34
|
+
|
35
|
+
def search
|
36
|
+
@search = SearchForm.new(params[:q])
|
37
|
+
if @search.valid?
|
38
|
+
@users = User.where(username: @search.username) # ...
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
```
|
43
|
+
|
44
|
+
and the view:
|
45
|
+
|
46
|
+
```rhtml
|
47
|
+
<%= form_for @search, url: form_path do |f| %>
|
48
|
+
<%= f.text_field :username %><br />
|
49
|
+
<%= f.datetime_select :created_at %><br />
|
50
|
+
<%= f.check_box :locked %><br />
|
51
|
+
<%= f.submit %>
|
52
|
+
<% end %>
|
53
|
+
```
|
54
|
+
|
55
|
+
If you use `simple_form` or `formtastic`, they automatically create date_time or boolean inputs based on your form object.
|
56
|
+
|
57
|
+
Also check out the [example](https://github.com/MSch/activemodel-form/tree/master/example) project.
|
58
|
+
|
59
|
+
## Future
|
60
|
+
|
61
|
+
This gem doesn't hook into any Rails (or `simple_form` or `formtastic`)
|
62
|
+
internals and doesn't monkey patch anything, it only uses the ActiveModel API.
|
63
|
+
So it should be future proof.
|
64
|
+
|
65
|
+
## Contributing
|
66
|
+
|
67
|
+
1. Fork it
|
68
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
69
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
70
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
71
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
|
3
|
+
require 'rake/testtask'
|
4
|
+
Rake::TestTask.new do |t|
|
5
|
+
t.test_files = FileList['spec/**/*_spec.rb']
|
6
|
+
t.verbose = true
|
7
|
+
end
|
8
|
+
|
9
|
+
task :pry do
|
10
|
+
require 'bundler/setup'
|
11
|
+
require 'pry'
|
12
|
+
require 'active_model-form'
|
13
|
+
Pry.start
|
14
|
+
end
|
15
|
+
|
16
|
+
task default: :test
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'active_model/form/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "activemodel-form"
|
8
|
+
gem.version = ActiveModel::Form::VERSION
|
9
|
+
gem.authors = ["Martin Schürrer"]
|
10
|
+
gem.email = ["martin@schuerrer.org"]
|
11
|
+
gem.description = %q{ActiveModel with support for booleans and datetimes in form helpers}
|
12
|
+
gem.summary = %q{}
|
13
|
+
gem.homepage = ""
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_runtime_dependency 'activemodel', '~> 3.2.7'
|
21
|
+
gem.add_runtime_dependency 'activesupport', '~> 3.2.7'
|
22
|
+
|
23
|
+
gem.add_development_dependency 'rake'
|
24
|
+
gem.add_development_dependency 'pry'
|
25
|
+
end
|
data/example/.gitignore
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
2
|
+
#
|
3
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
4
|
+
# or operating system, you probably want to add a global ignore instead:
|
5
|
+
# git config --global core.excludesfile ~/.gitignore_global
|
6
|
+
|
7
|
+
# Ignore bundler config
|
8
|
+
/.bundle
|
9
|
+
|
10
|
+
# Ignore the default SQLite database.
|
11
|
+
*.sqlite3
|
12
|
+
|
13
|
+
# Ignore all logfiles and tempfiles.
|
14
|
+
/log/*.log
|
15
|
+
/tmp
|
data/example/Gemfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gem 'rails', '3.2.7'
|
4
|
+
|
5
|
+
# Bundle edge Rails instead:
|
6
|
+
# gem 'rails', :git => 'git://github.com/rails/rails.git'
|
7
|
+
|
8
|
+
gem 'sqlite3'
|
9
|
+
gem 'pry'
|
10
|
+
|
11
|
+
gem 'activemodel-form', path: '..'
|
12
|
+
gem 'formtastic'
|
13
|
+
gem 'simple_form'
|
data/example/README.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
class FormsController < ApplicationController
|
2
|
+
class SearchForm < ActiveModel::Form
|
3
|
+
self.model_name = 'q'
|
4
|
+
attribute :username, :string
|
5
|
+
attribute :created_at, :date_time
|
6
|
+
attribute :locked, :boolean
|
7
|
+
|
8
|
+
validates_presence_of :username
|
9
|
+
validates_presence_of :created_at
|
10
|
+
end
|
11
|
+
|
12
|
+
def new
|
13
|
+
@search = SearchForm.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def create
|
17
|
+
@search = SearchForm.new(params[:q])
|
18
|
+
@search.valid?
|
19
|
+
render 'new'
|
20
|
+
end
|
21
|
+
|
22
|
+
def show
|
23
|
+
redirect_to action: 'new'
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<h1>simple_form</h1>
|
2
|
+
<%= simple_form_for @search, url: form_path do |f| %>
|
3
|
+
<%= f.input :username %>
|
4
|
+
<%= f.input :created_at %>
|
5
|
+
<%= f.input :locked %>
|
6
|
+
<%= f.button :submit %>
|
7
|
+
<% end %>
|
8
|
+
|
9
|
+
<h1>formtastic</h1>
|
10
|
+
<%= semantic_form_for @search, url: form_path do |f| %>
|
11
|
+
<%= f.input :username %>
|
12
|
+
<%= f.input :created_at %>
|
13
|
+
<%= f.input :locked %>
|
14
|
+
|
15
|
+
<%= f.action :submit, :as => :button %>
|
16
|
+
<% end %>
|
17
|
+
|
18
|
+
<h1 style="clear: both; padding-top: 20px">Plain Rails</h1>
|
19
|
+
<%= form_for @search, url: form_path do |f| %>
|
20
|
+
<%= f.text_field :username %><br />
|
21
|
+
<%= f.datetime_select :created_at %><br />
|
22
|
+
<%= f.check_box :locked %><br />
|
23
|
+
<%= f.submit %>
|
24
|
+
<% end %>
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require 'rails/all'
|
4
|
+
|
5
|
+
if defined?(Bundler)
|
6
|
+
# If you precompile assets before deploying to production, use this line
|
7
|
+
Bundler.require(*Rails.groups(:assets => %w(development test)))
|
8
|
+
# If you want your assets lazily compiled in production, use this line
|
9
|
+
# Bundler.require(:default, :assets, Rails.env)
|
10
|
+
end
|
11
|
+
|
12
|
+
module Example
|
13
|
+
class Application < Rails::Application
|
14
|
+
# Settings in config/environments/* take precedence over those specified here.
|
15
|
+
# Application configuration should go into files in config/initializers
|
16
|
+
# -- all .rb files in that directory are automatically loaded.
|
17
|
+
|
18
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
19
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
20
|
+
|
21
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
22
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
23
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
24
|
+
|
25
|
+
# Activate observers that should always be running.
|
26
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
27
|
+
|
28
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
29
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
30
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
31
|
+
|
32
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
33
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
34
|
+
# config.i18n.default_locale = :de
|
35
|
+
|
36
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
37
|
+
config.encoding = "utf-8"
|
38
|
+
|
39
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
40
|
+
config.filter_parameters += [:password]
|
41
|
+
|
42
|
+
# Enable escaping HTML in JSON.
|
43
|
+
config.active_support.escape_html_entities_in_json = true
|
44
|
+
|
45
|
+
# Use SQL instead of Active Record's schema dumper when creating the database.
|
46
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
47
|
+
# like if you have constraints or database-specific column types
|
48
|
+
# config.active_record.schema_format = :sql
|
49
|
+
|
50
|
+
# Enforce whitelist mode for mass assignment.
|
51
|
+
# This will create an empty whitelist of attributes available for mass-assignment for all models
|
52
|
+
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
|
53
|
+
# parameters by using an attr_accessible or attr_protected declaration.
|
54
|
+
config.active_record.whitelist_attributes = true
|
55
|
+
|
56
|
+
# Enable the asset pipeline
|
57
|
+
config.assets.enabled = true
|
58
|
+
|
59
|
+
# Version of your assets, change this if you want to expire all your assets
|
60
|
+
config.assets.version = '1.0'
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
Example::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
|
+
# Raise exception on mass assignment protection for Active Record models
|
26
|
+
config.active_record.mass_assignment_sanitizer = :strict
|
27
|
+
|
28
|
+
# Log the query plan for queries taking more than this (works
|
29
|
+
# with SQLite, MySQL, and PostgreSQL)
|
30
|
+
config.active_record.auto_explain_threshold_in_seconds = 0.5
|
31
|
+
|
32
|
+
# Do not compress assets
|
33
|
+
config.assets.compress = false
|
34
|
+
|
35
|
+
# Expands the lines which load the assets
|
36
|
+
config.assets.debug = true
|
37
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
Example::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# Code is not reloaded between requests
|
5
|
+
config.cache_classes = true
|
6
|
+
|
7
|
+
# Full error reports are disabled and caching is turned on
|
8
|
+
config.consider_all_requests_local = false
|
9
|
+
config.action_controller.perform_caching = true
|
10
|
+
|
11
|
+
# Disable Rails's static asset server (Apache or nginx will already do this)
|
12
|
+
config.serve_static_assets = false
|
13
|
+
|
14
|
+
# Compress JavaScripts and CSS
|
15
|
+
config.assets.compress = true
|
16
|
+
|
17
|
+
# Don't fallback to assets pipeline if a precompiled asset is missed
|
18
|
+
config.assets.compile = false
|
19
|
+
|
20
|
+
# Generate digests for assets URLs
|
21
|
+
config.assets.digest = true
|
22
|
+
|
23
|
+
# Defaults to nil and saved in location specified by config.assets.prefix
|
24
|
+
# config.assets.manifest = YOUR_PATH
|
25
|
+
|
26
|
+
# Specifies the header that your server uses for sending files
|
27
|
+
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
|
28
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
|
29
|
+
|
30
|
+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
31
|
+
# config.force_ssl = true
|
32
|
+
|
33
|
+
# See everything in the log (default is :info)
|
34
|
+
# config.log_level = :debug
|
35
|
+
|
36
|
+
# Prepend all log lines with the following tags
|
37
|
+
# config.log_tags = [ :subdomain, :uuid ]
|
38
|
+
|
39
|
+
# Use a different logger for distributed setups
|
40
|
+
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
|
41
|
+
|
42
|
+
# Use a different cache store in production
|
43
|
+
# config.cache_store = :mem_cache_store
|
44
|
+
|
45
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server
|
46
|
+
# config.action_controller.asset_host = "http://assets.example.com"
|
47
|
+
|
48
|
+
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
|
49
|
+
# config.assets.precompile += %w( search.js )
|
50
|
+
|
51
|
+
# Disable delivery errors, bad email addresses will be ignored
|
52
|
+
# config.action_mailer.raise_delivery_errors = false
|
53
|
+
|
54
|
+
# Enable threaded mode
|
55
|
+
# config.threadsafe!
|
56
|
+
|
57
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
58
|
+
# the I18n.default_locale when a translation can not be found)
|
59
|
+
config.i18n.fallbacks = true
|
60
|
+
|
61
|
+
# Send deprecation notices to registered listeners
|
62
|
+
config.active_support.deprecation = :notify
|
63
|
+
|
64
|
+
# Log the query plan for queries taking more than this (works
|
65
|
+
# with SQLite, MySQL, and PostgreSQL)
|
66
|
+
# config.active_record.auto_explain_threshold_in_seconds = 0.5
|
67
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
Example::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# The test environment is used exclusively to run your application's
|
5
|
+
# test suite. You never need to work with it otherwise. Remember that
|
6
|
+
# your test database is "scratch space" for the test suite and is wiped
|
7
|
+
# and recreated between test runs. Don't rely on the data there!
|
8
|
+
config.cache_classes = true
|
9
|
+
|
10
|
+
# Configure static asset server for tests with Cache-Control for performance
|
11
|
+
config.serve_static_assets = true
|
12
|
+
config.static_cache_control = "public, max-age=3600"
|
13
|
+
|
14
|
+
# Log error messages when you accidentally call methods on nil
|
15
|
+
config.whiny_nils = true
|
16
|
+
|
17
|
+
# Show full error reports and disable caching
|
18
|
+
config.consider_all_requests_local = true
|
19
|
+
config.action_controller.perform_caching = false
|
20
|
+
|
21
|
+
# Raise exceptions instead of rendering exception templates
|
22
|
+
config.action_dispatch.show_exceptions = false
|
23
|
+
|
24
|
+
# Disable request forgery protection in test environment
|
25
|
+
config.action_controller.allow_forgery_protection = false
|
26
|
+
|
27
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
28
|
+
# The :test delivery method accumulates sent emails in the
|
29
|
+
# ActionMailer::Base.deliveries array.
|
30
|
+
config.action_mailer.delivery_method = :test
|
31
|
+
|
32
|
+
# Raise exception on mass assignment protection for Active Record models
|
33
|
+
config.active_record.mass_assignment_sanitizer = :strict
|
34
|
+
|
35
|
+
# Print deprecation notices to the stderr
|
36
|
+
config.active_support.deprecation = :stderr
|
37
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
4
|
+
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
5
|
+
|
6
|
+
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
7
|
+
# Rails.backtrace_cleaner.remove_silencers!
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# --------------------------------------------------------------------------------------------------
|
4
|
+
# Please note: If you're subclassing Formtastic::FormBuilder, Formtastic uses
|
5
|
+
# class_attribute for these configuration attributes instead of the deprecated
|
6
|
+
# class_inheritable_attribute. The behaviour is slightly different with subclasses (especially
|
7
|
+
# around attributes with Hash or Array) values, so make sure you understand what's happening.
|
8
|
+
# See the documentation for class_attribute in ActiveSupport for more information.
|
9
|
+
# --------------------------------------------------------------------------------------------------
|
10
|
+
|
11
|
+
# Set the default text field size when input is a string. Default is nil.
|
12
|
+
# Formtastic::FormBuilder.default_text_field_size = 50
|
13
|
+
|
14
|
+
# Set the default text area height when input is a text. Default is 20.
|
15
|
+
# Formtastic::FormBuilder.default_text_area_height = 5
|
16
|
+
|
17
|
+
# Set the default text area width when input is a text. Default is nil.
|
18
|
+
# Formtastic::FormBuilder.default_text_area_width = 50
|
19
|
+
|
20
|
+
# Should all fields be considered "required" by default?
|
21
|
+
# Defaults to true.
|
22
|
+
# Formtastic::FormBuilder.all_fields_required_by_default = true
|
23
|
+
|
24
|
+
# Should select fields have a blank option/prompt by default?
|
25
|
+
# Defaults to true.
|
26
|
+
# Formtastic::FormBuilder.include_blank_for_select_by_default = true
|
27
|
+
|
28
|
+
# Set the string that will be appended to the labels/fieldsets which are required
|
29
|
+
# It accepts string or procs and the default is a localized version of
|
30
|
+
# '<abbr title="required">*</abbr>'. In other words, if you configure formtastic.required
|
31
|
+
# in your locale, it will replace the abbr title properly. But if you don't want to use
|
32
|
+
# abbr tag, you can simply give a string as below
|
33
|
+
# Formtastic::FormBuilder.required_string = "(required)"
|
34
|
+
|
35
|
+
# Set the string that will be appended to the labels/fieldsets which are optional
|
36
|
+
# Defaults to an empty string ("") and also accepts procs (see required_string above)
|
37
|
+
# Formtastic::FormBuilder.optional_string = "(optional)"
|
38
|
+
|
39
|
+
# Set the way inline errors will be displayed.
|
40
|
+
# Defaults to :sentence, valid options are :sentence, :list, :first and :none
|
41
|
+
# Formtastic::FormBuilder.inline_errors = :sentence
|
42
|
+
# Formtastic uses the following classes as default for hints, inline_errors and error list
|
43
|
+
|
44
|
+
# If you override the class here, please ensure to override it in your stylesheets as well
|
45
|
+
# Formtastic::FormBuilder.default_hint_class = "inline-hints"
|
46
|
+
# Formtastic::FormBuilder.default_inline_error_class = "inline-errors"
|
47
|
+
# Formtastic::FormBuilder.default_error_list_class = "errors"
|
48
|
+
|
49
|
+
# Set the method to call on label text to transform or format it for human-friendly
|
50
|
+
# reading when formtastic is used without object. Defaults to :humanize.
|
51
|
+
# Formtastic::FormBuilder.label_str_method = :humanize
|
52
|
+
|
53
|
+
# Set the array of methods to try calling on parent objects in :select and :radio inputs
|
54
|
+
# for the text inside each @<option>@ tag or alongside each radio @<input>@. The first method
|
55
|
+
# that is found on the object will be used.
|
56
|
+
# Defaults to ["to_label", "display_name", "full_name", "name", "title", "username", "login", "value", "to_s"]
|
57
|
+
# Formtastic::FormBuilder.collection_label_methods = [
|
58
|
+
# "to_label", "display_name", "full_name", "name", "title", "username", "login", "value", "to_s"]
|
59
|
+
|
60
|
+
# Additionally, you can customize the order for specific types of inputs.
|
61
|
+
# This is configured on a type basis and if a type is not found it will
|
62
|
+
# fall back to the default order as defined by #inline_order
|
63
|
+
# Formtastic::FormBuilder.custom_inline_order[:checkbox] = [:errors, :hints, :input]
|
64
|
+
# Formtastic::FormBuilder.custom_inline_order[:select] = [:hints, :input, :errors]
|
65
|
+
|
66
|
+
# Specifies if labels/hints for input fields automatically be looked up using I18n.
|
67
|
+
# Default value: true. Overridden for specific fields by setting value to true,
|
68
|
+
# i.e. :label => true, or :hint => true (or opposite depending on initialized value)
|
69
|
+
# Formtastic::FormBuilder.i18n_lookups_by_default = false
|
70
|
+
|
71
|
+
# Specifies if I18n lookups of the default I18n Localizer should be cached to improve performance.
|
72
|
+
# Defaults to false.
|
73
|
+
# Formtastic::FormBuilder.i18n_cache_lookups = true
|
74
|
+
|
75
|
+
# Specifies the class to use for localization lookups. You can create your own
|
76
|
+
# class and use it instead by subclassing Formtastic::Localizer (which is the default).
|
77
|
+
# Formtastic::FormBuilder.i18n_localizer = MyOwnLocalizer
|
78
|
+
|
79
|
+
# You can add custom inputs or override parts of Formtastic by subclassing Formtastic::FormBuilder and
|
80
|
+
# specifying that class here. Defaults to Formtastic::FormBuilder.
|
81
|
+
# Formtastic::Helpers::FormHelper.builder = MyCustomBuilder
|
82
|
+
|
83
|
+
# You can opt-in to Formtastic's use of the HTML5 `required` attribute on `<input>`, `<select>`
|
84
|
+
# and `<textarea>` tags by setting this to false (defaults to true).
|
85
|
+
# Formtastic::FormBuilder.use_required_attribute = true
|
86
|
+
|
87
|
+
# You can opt-in to new HTML5 browser validations (for things like email and url inputs) by setting
|
88
|
+
# this to false. Doing so will add a `novalidate` attribute to the `<form>` tag.
|
89
|
+
# See http://diveintohtml5.org/forms.html#validation for more info.
|
90
|
+
# Formtastic::FormBuilder.perform_browser_validations = true
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Add new inflection rules using the following format
|
4
|
+
# (all these examples are active by default):
|
5
|
+
# ActiveSupport::Inflector.inflections do |inflect|
|
6
|
+
# inflect.plural /^(ox)$/i, '\1en'
|
7
|
+
# inflect.singular /^(ox)en/i, '\1'
|
8
|
+
# inflect.irregular 'person', 'people'
|
9
|
+
# inflect.uncountable %w( fish sheep )
|
10
|
+
# end
|
11
|
+
#
|
12
|
+
# These inflection rules are supported but not enabled by default:
|
13
|
+
# ActiveSupport::Inflector.inflections do |inflect|
|
14
|
+
# inflect.acronym 'RESTful'
|
15
|
+
# end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key for verifying the integrity of signed cookies.
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
5
|
+
# Make sure the secret is at least 30 characters and all random,
|
6
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
7
|
+
Example::Application.config.secret_token = 'e9e87622a00af1ac92823eed4b8b15a443a7aef0e55d84019ebd71f07ba669a30579ede81134e3a40fe1af104527c66a930278f3bed64aa4882c1ca1463cb93b'
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
Example::Application.config.session_store :cookie_store, key: '_example_session'
|
4
|
+
|
5
|
+
# Use the database for sessions instead of the cookie-based default,
|
6
|
+
# which shouldn't be used to store highly confidential information
|
7
|
+
# (create the session table with "rails generate session_migration")
|
8
|
+
# Example::Application.config.session_store :active_record_store
|