| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|\
| |
| |
| |
| | |
Conflicts:
activemodel/lib/active_model/errors.rb
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Since we're dealing with a new array instance, it's safe to use map! and
we avoid an extra array object.
Also remove the symbolize_keys! from AttributeMethodMatcher, since it's
an internal class that always receives symbol keys from the prefix/suffix
methods implementations.
|
| |
| |
| |
| |
| | |
Since we're not directly requiring the reverse_merge extension, we can
avoid another hash creation by using default_hash.merge! instead.
|
| |
| |
| |
| |
| |
| |
| |
| | |
There's no need to create two extra hashes with options.merge(another_hash),
with the goal of setting only one value, so lets just set it.
Also refactor validates_each to use _merge_attributes, like other
validates_* helpers do.
|
| | |
|
| |
| |
| |
| |
| |
| |
| | |
These _define class methods don't need to be exposed to objects that
extend ActiveModel::Callbacks.
Also use merge! options to avoid the creation of an extra hash.
|
| | |
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The keys of the error messages are actually attribute names. It makes
the documentation easier to understand:
# Returns +true+ if the error messages include an error for the given
# +attribute+, +false+ otherwise.
#
# person.errors.messages # => { :name => ["can not be nil"] }
# person.errors.include?(:name) # => true
# person.errors.include?(:age) # => false
def include?(attribute)
(v = messages[attribute]) && v.any?
end
|
|\ |
|
| | |
|
| | |
|
| | |
|
| |
| |
| |
| | |
skip]
|
| | |
|
| | |
|
| | |
|
| | |
|
|\ \
| | |
| | | |
Dynamic finders for aliased attributes
|
| | |
| | |
| | |
| | |
| | | |
previously dynamic finders only worked in combination with the actual
column name and not its alias defined with #alias_attribute
|
| | |
| | |
| | |
| | | |
skip]
|
|/ / |
|
|/
|
|
|
| |
Get rid of ActiveModel::Configuration, make better use of
ActiveSupport::Concern + class_attribute, etc.
|
|\ |
|
| | |
|
| |
| |
| |
| |
| | |
* Moved the simplest case--enable/disable all on all--to the top.
* Made clear what "ORM" means to avoid having to teach people how to solve "uninitialized constant ORM"
errors in their test reports.
|
| |
| |
| |
| | |
security (http://homakov.blogspot.co.uk/2012/05/saferweb-injects-in-various-ruby.html)
|
|\ \
| | |
| | | |
Compact array of values added to PermissionSet instance
|
| |/ |
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Changes:
* Update `include_root_in_json` default value to false for default value
to false for `ActiveModel::Serializers::JSON`.
* Remove unnecessary change to include_root_in_json option in
wrap_parameters template.
* Update `as_json` documentation.
* Fix JSONSerialization tests.
Problem:
It's confusing that AM serializers behave differently from AR,
even when AR objects include AM serializers module.
class User < ActiveRecord::Base; end
class Person
include ActiveModel::Model
include ActiveModel::AttributeMethods
include ActiveModel::Serializers::JSON
attr_accessor :name, :age
def attributes
instance_values
end
end
user.as_json
=> {"id"=>1, "name"=>"Konata Izumi", "age"=>16, "awesome"=>true}
# root is not included
person.as_json
=> {"person"=>{"name"=>"Francesco", "age"=>22}}
# root is included
ActiveRecord::Base.include_root_in_json
=> false
Person.include_root_in_json
=> true
# different default values for include_root_in_json
Proposal:
Change the default value of AM serializers to false, update
the misleading documentation and remove unnecessary change
to false of include_root_in_json option with AR objects.
class User < ActiveRecord::Base; end
class Person
include ActiveModel::Model
include ActiveModel::AttributeMethods
include ActiveModel::Serializers::JSON
attr_accessor :name, :age
def attributes
instance_values
end
end
user.as_json
=> {"id"=>1, "name"=>"Konata Izumi", "age"=>16, "awesome"=>true}
# root is not included
person.as_json
=> {"name"=>"Francesco", "age"=>22}
# root is not included
ActiveRecord::Base.include_root_in_json
=> false
Person.include_root_in_json
=> false
# same behaviour, more consistent
Fixes #6578.
|
| |
|
|\
| |
| |
| |
| | |
kuroda/translation_of_deeply_nested_model_attributes
Fix human attribute_name to handle deeply nested attributes
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
When a model nests another model that also nests yet another model
using accepts_nested_attributes_for method, its Errors object can
have an attribute name with "contacts.addresses.street" style.
In this case, the dots within the namespace should be substituted
with slashes so that we can provide the translation under the
"activemodel.attributes.person/contacts/addresses.street" key.
This commit is related to #3859.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Passing a falsey option value for a validator currently causes that validator to
be enabled, just like "true":
ActiveModel.validates :foo, :presence => false
This is rather counterintuitive, and makes it inconvenient to wrap `validates` in
methods which may conditionally enable different validators.
As an example, one is currently forced to write:
def has_slug(source_field, options={:unique => true})
slugger = Proc.new { |r| r[:slug] = self.class.sluggify(r[source_field]) if r[:slug].blank? }
before_validation slugger
validations = { :presence => true, :slug => true }
if options[:unique]
validations[:uniqueness] = true
end
validates :slug, validations
end
because the following reasonable-looking alternative fails to work as expected:
def has_slug(source_field, options={:unique => true})
slugger = Proc.new { |r| r[:slug] = self.class.sluggify(r[source_field]) if r[:slug].blank? }
before_validation slugger
validates :slug, :presence => true, :slug => true, :uniqueness => options[:unique]
end
(This commit includes a test, and all activemodel and activerecord tests pass as before.)
|
|\ \ |
|
| | | |
|
|\ \ \
| |/ /
|/| |
| | |
| | | |
ayamomiji/add-self-to-allow-method-name-using-ruby-keyword
add `self.` to allow method name using ruby keyword
|
| | |
| | |
| | |
| | | |
column that named as a ruby keyword
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
XmlMini define the xml 'datatime', but according to
http://www.w3.org/TR/xmlschema-2/#dateTime could be better
change this to 'dateTime' with upper case letter 'T.
So 'DateTime' and 'Time' are redefined from 'datetime' to 'dateTime'
add the changing to the changelog
|
| | | |
|