recipients user.email, @admin_email
subject “MyApp - New part created.”
body :user => user
class PartObserver < ActiveRecord::Observer
It looks as if I can only pass in the object of the given class into
In the case above, ‘part’ is the only one that is being passed by to
Can I pass more objects to the method, created_successfully (model/
I tried looking at the api docs and
no success. Can someone please shed some light into this?
These are instance variables.If need this entire for the class declare
it as class varibale using @@
No, actually, that part is fine. Since the @variables are defined
outside of a method, they are instance variables on the Class object –
they function like @@variables but are apparently more reliable.
In short, top level instance variables loose their scope and must be
qualified using the class name (i.e. .variable_name) within
instance methods instead of using @variable_name. However, you have
access to a top level instance variable within a class method. For
take the following:
@some_variable = 1
class << self
print "inner method without qualification => "
print "inner method with qualification => "
print "outer method => "
var = SomeVariable.new
For the parameter arguments to the observer and mailer, yes I did
2 arguments being “user, part” and I got an error being “2 for 1 error”
that the object, “user” was nil (which is weird because I set up print
statements in the observer to print out various attributes of the “user”
object (ie. first name, surname and so forth) and it worked fine.
For the time being I stuck to passing 1 parameter argument and used the
object’s associations to grab the other object when I needed it down the
line. It’s been working well.
Has any body actually done this before ( as in pass in more than 1
to the observer and the corresponding action method (in my case the