Hello all.
In this example, as i understand that *included* block is running when
Exclaimable module is included in Person and *after* a Person class methods
are 'initialized'
> require 'active_support/concern'
>
> module Exclaimable
> extend ActiveSupport::Concern
> included do
> self.new.hello
> end
> end
>
> class Person
> include Exclaimable
> def hello
> puts 'person hello'
> end
> end
Output: Exception: NoMethodError: undefined method `hello' for
#<Person:0x00000103cbdcd0>
But i see that, Person class doesn't have hello method, why ? Please, help
!
So, i can't understand - what diifference between
> included do
> self.new.hello
> end
and class method:
> self.included(base)
> base.new.hello
> end
Both code get same error ( see above )
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/c795f3da-8b7f-4fbd-b4d9-49fbe1c01d9b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.