Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fixed ActiveModel::Model's inclusion chain #11004

Merged
merged 1 commit into from

4 participants

@fredwu

cc @josevalim @drogus

master version #11002

@josevalim josevalim merged commit 6ed17e2 into rails:4-0-stable
@woto

Sorry for bad English. This commit will raise error if there no ancestors.

e3dc10f#commitcomment-3457605
In test case there is DefaultValue module included before ActiveModel::Model

@rafaelfranca

Yes, @fredwu could you check this

@fredwu

I'm already on it. :)

@fredwu fredwu referenced this pull request from a commit in fredwu/rails
@fredwu fredwu Fixes AciveModel::Model with no ancestors, fixes #11004 61765f9
@fredwu fredwu referenced this pull request from a commit in fredwu/rails
@fredwu fredwu Fixes AciveModel::Model with no ancestors, fixes #11004 ca218a3
@fredwu fredwu referenced this pull request from a commit in fredwu/rails
@fredwu fredwu Fixes AciveModel::Model with no ancestors, fixes #11004 cbb0b72
@josevalim josevalim referenced this pull request from a commit
@fredwu fredwu Fixes AciveModel::Model with no ancestors, fixes #11004
Signed-off-by: José Valim <jose.valim@plataformatec.com.br>
0b502cb
@josevalim josevalim referenced this pull request from a commit
@fredwu fredwu Fixes AciveModel::Model with no ancestors, fixes #11004
Signed-off-by: José Valim <jose.valim@plataformatec.com.br>
c7f47ee
@josevalim josevalim referenced this pull request from a commit
@fredwu fredwu Fixes AciveModel::Model with no ancestors, fixes #11004
Signed-off-by: José Valim <jose.valim@plataformatec.com.br>
84bb0b0
@woto

New problem with last commit on ActiveModel.
@fredwu Please look at this woto@9fc20cf
May be i am doing something wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 19, 2013
  1. @fredwu
This page is out of date. Refresh to see the latest.
View
2  activemodel/lib/active_model/model.rb
@@ -79,6 +79,8 @@ def initialize(params={})
params.each do |attr, value|
self.public_send("#{attr}=", value)
end if params
+
+ super
end
# Indicates if the model is persisted. Default is +false+.
View
12 activemodel/test/cases/model_test.rb
@@ -3,7 +3,14 @@
class ModelTest < ActiveModel::TestCase
include ActiveModel::Lint::Tests
+ module DefaultValue
+ def initialize(*args)
+ @attr ||= 'default value'
+ end
+ end
+
class BasicModel
+ include DefaultValue
include ActiveModel::Model
attr_accessor :attr
end
@@ -29,4 +36,9 @@ def test_persisted_is_always_false
object = BasicModel.new(:attr => "value")
assert object.persisted? == false
end
+
+ def test_mixin_inclusion_chain
+ object = BasicModel.new
+ assert_equal object.attr, 'default value'
+ end
end
Something went wrong with that request. Please try again.