context.instance_variables

6 views
Skip to first unread message

rellik

unread,
Apr 13, 2007, 2:48:57 AM4/13/07
to MOle Plugin
First of all, let me say how great this plugin looks! It's a tool I'm
sure I'll use on quite a few projects.

I am trying to get it set up, but am having some problems. I can't
seem to access my instance variables. I get an 'undefined method'
error.

My code:

RequestsController.after(:feature=>:view) do |context, feature, args,
block|
Mole::DbMole.mole_it(context, feature,
context.session[:user], :some_var =>
context.instance_variable.get(@foo))
end

My error:
>>> Mole Error: After-Filterundefined method `instance_variable' for #<RequestsController:0xb7694a94>

Fernand Galiana

unread,
Apr 13, 2007, 10:06:36 AM4/13/07
to mole-...@googlegroups.com
Hi,

   Thanks for the kind words...

   The actual method call to get the controller instance variable should be
   context.instance_variable_get and not context.instance_variable.get

-Fernand

rellik

unread,
Apr 13, 2007, 7:51:15 PM4/13/07
to MOle Plugin
Thanks. You might consider updating your blog to reflect that.

In your original post:

MyController.before( :feature => :show ) do |context, feature, args,


block| Mole::DbMole.mole_it( context, feature,

context.session[:user_id],
:some_var => context.instance_variable.get(@myVar))

On Apr 13, 9:06 am, "Fernand Galiana" <fernand.gali...@gmail.com>
wrote:


> Hi,
>
> Thanks for the kind words...
>
> The actual method call to get the controller instance variable should be
> context.instance_variable_get and not context.instance_variable.get
>
> -Fernand
>

Fernand Galiana

unread,
Apr 14, 2007, 1:53:31 AM4/14/07
to mole-...@googlegroups.com
Doh !! Sorry, I will update it...

Thanks

On 4/13/07, rellik <patrick...@gmail.com> wrote:

rellik

unread,
Apr 15, 2007, 3:03:52 AM4/15/07
to MOle Plugin
I changed the call to instance_variable_get() but am getting the
following error:
>>> Mole Error: After-Filternil is not a symbol

My code is:

### Code ###


RequestsController.after(:feature=>:view) do |context, feature,
args, block|
Mole::DbMole.mole_it( context, feature,

context.session[:user], :my_foo=>context.instance_variable_get(@foo))
end
### End ###

@foo is definitely set in the view() method, as it is used in the
displayed view.

On Apr 14, 12:53 am, "Fernand Galiana" <fernand.gali...@gmail.com>
wrote:


> Doh !! Sorry, I will update it...
>
> Thanks
>

Fernand Galiana

unread,
Apr 15, 2007, 3:35:37 AM4/15/07
to mole-...@googlegroups.com
Hum... I suspect something went wrong while persisting the mole info...
I have added some extra debug info to the mole, but in the mean time
try to stick the following line in the mole/module.rb

I am sure our line# won't match but you should see a rescue block that will
look something like:

rescue => ca_boom
  klass.mole_log ">> Mole Error: After-Filter " + ca_boom
end

Add this line to the rescue block

ca_boom.backtrace.each { |l| klass.mole_log l }

And send us the exception trace...

-Fernand


On 4/15/07, rellik <patrick...@gmail.com > wrote:

I changed the call to instance_variable_get() but am getting the
following error:
>>> Mole Error: After-Filternil is not a symbol

My code is:

### Code ###
  RequestsController.after(:feature=>:view) do |context, feature,
args, block|
    Mole::DbMole.mole_it ( context, feature,

context.session[:user], :my_foo=>context.instance_variable_get(@foo))
  end
### End ###

@foo is definitely set in the view() method, as it is used in the
displayed view.

On Apr 14, 12:53 am, "Fernand Galiana" < fernand.gali...@gmail.com>
wrote:
> Doh !! Sorry, I will update it...
>
> Thanks
>
> On 4/13/07, rellik < patrick.schl...@gmail.com> wrote:
>
>
>
> > Thanks.  You might consider updating your blog to reflect that.
>
> > In your original post:
>
> > MyController.before ( :feature => :show ) do |context, feature, args,

rellik

unread,
Apr 15, 2007, 4:17:55 AM4/15/07
to MOle Plugin
./script/../config/../app/controllers/requests_controller.rb:562:in
`instance_variable_get'
./script/../config/../app/controllers/requests_controller.rb:562
(eval):36:in `view'
(eval):36:in `view'
./script/../config/../vendor/rails/actionpack/lib/action_controller/
base.rb:1095:in `perform_action_without_filters'
./script/../config/../vendor/rails/actionpack/lib/action_controller/
filters.rb:632:in `call_filter'
./script/../config/../vendor/rails/actionpack/lib/action_controller/
filters.rb:638:in `call_filter'
./script/../config/../vendor/rails/actionpack/lib/action_controller/
filters.rb:438:in `call'
./script/../config/../vendor/rails/actionpack/lib/action_controller/
filters.rb:637:in `call_filter'
./script/../config/../vendor/rails/actionpack/lib/action_controller/
filters.rb:619:in `perform_action_without_benchmark'
./script/../config/../vendor/rails/actionpack/lib/action_controller/
benchmarking.rb:66:in `perform_action_without_rescue'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
./script/../config/../vendor/rails/actionpack/lib/action_controller/
benchmarking.rb:66:in `perform_action_without_rescue'
./script/../config/../vendor/rails/actionpack/lib/action_controller/
rescue.rb:83:in `perform_action'
./script/../config/../vendor/rails/actionpack/lib/action_controller/
base.rb:430:in `process_without_filters'
./script/../config/../vendor/rails/actionpack/lib/action_controller/
filters.rb:624:in `process_without_session_management_support'
./script/../config/../vendor/rails/actionpack/lib/action_controller/
session_management.rb:114:in `process'
./script/../config/../vendor/rails/actionpack/lib/action_controller/
base.rb:330:in `process'
./script/../config/../vendor/rails/railties/lib/dispatcher.rb:41:in
`dispatch'
./script/../config/../vendor/rails/railties/lib/webrick_server.rb:
113:in `handle_dispatch'
./script/../config/../vendor/rails/railties/lib/webrick_server.rb:
79:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
./script/../config/../vendor/rails/railties/lib/webrick_server.rb:
63:in `dispatch'
./script/../config/../vendor/rails/railties/lib/commands/servers/
webrick.rb:59
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require'
./script/../config/../vendor/rails/activesupport/lib/active_support/
dependencies.rb:496:in `require'
./script/../config/../vendor/rails/activesupport/lib/active_support/
dependencies.rb:343:in `new_constants_in'
./script/../config/../vendor/rails/activesupport/lib/active_support/
dependencies.rb:496:in `require'
./script/../config/../vendor/rails/railties/lib/commands/server.rb:39
script/server:3

>>> Mole Error: After-Filternil is not a symbol


On Apr 15, 2:35 am, "Fernand Galiana" <fernand.gali...@gmail.com>
wrote:


> Hum... I suspect something went wrong while persisting the mole info...
> I have added some extra debug info to the mole, but in the mean time
> try to stick the following line in the mole/module.rb
>
> I am sure our line# won't match but you should see a rescue block that will
> look something like:
>
> rescue => ca_boom
> klass.mole_log ">> Mole Error: After-Filter " + ca_boom
> end
>
> Add this line to the rescue block
>
> ca_boom.backtrace.each { |l| klass.mole_log l }
>
> And send us the exception trace...
>
> -Fernand
>

> On 4/15/07, rellik <patrick.schl...@gmail.com> wrote:
>
>
>
> > I changed the call to instance_variable_get() but am getting the
> > following error:
> > >>> Mole Error: After-Filternil is not a symbol
>
> > My code is:
>
> > ### Code ###
> > RequestsController.after(:feature=>:view) do |context, feature,
> > args, block|

> > Mole::DbMole.mole_it( context, feature,


> > context.session[:user], :my_foo=>context.instance_variable_get(@foo))
> > end
> > ### End ###
>
> > @foo is definitely set in the view() method, as it is used in the
> > displayed view.
>
> > On Apr 14, 12:53 am, "Fernand Galiana" <fernand.gali...@gmail.com>
> > wrote:
> > > Doh !! Sorry, I will update it...
>
> > > Thanks
>
> > > On 4/13/07, rellik <patrick.schl...@gmail.com> wrote:
>
> > > > Thanks. You might consider updating your blog to reflect that.
>
> > > > In your original post:
>

> > > > MyController.before( :feature => :show ) do |context, feature, args,

Fernand Galiana

unread,
Apr 15, 2007, 4:44:36 AM4/15/07
to mole-...@googlegroups.com
Ah -- The actual call should be instance_variable_get( "@foo" ) and not
instance_variable_get( @foo )

-Fernand

On 4/15/07, rellik < patrick...@gmail.com> wrote:

rellik

unread,
Apr 15, 2007, 5:38:27 AM4/15/07
to MOle Plugin
That makes a lot of sense... although it does seem odd that you pass
it "@foo" instead of "foo".. seems repetitive, since the method
itself is called instance_variable_get.

Thanks.. this will greatly change the informativeness of the mole
reports :)

On Apr 15, 3:44 am, "Fernand Galiana" <fernand.gali...@gmail.com>
wrote:


> Ah -- The actual call should be instance_variable_get( "@foo" ) and not
> instance_variable_get( @foo )
>
> -Fernand
>

rellik

unread,
Apr 15, 2007, 5:48:43 PM4/15/07
to MOle Plugin
As before, you might consider updating the blog example to reflect
this correct usage

Fernand Galiana

unread,
Apr 15, 2007, 6:55:26 PM4/15/07
to mole-...@googlegroups.com
Rats... Forgot about that. Thanks for the reminder Patrick !!

-Fernand

On 4/15/07, rellik <patrick...@gmail.com > wrote:
> > > > >   RequestsController.after (:feature=>:view) do |context, feature,
Reply all
Reply to author
Forward
0 new messages