Skip to content

Loading…

after_initialize bug #45

Open
xrorox opened this Issue · 3 comments

2 participants

@xrorox

Hi,

I have found a bug in apotomo's hooks.

#gère l'affichage des onglets. L'onglet terminer n'apparait que si on passe la session
def onglets

setup!
render 

end

private
def setup!
@corrige =options[:corrige]
end

This works as expected. But if you try to DRY this, this way :

after_initialize :setup!

def onglets

setup!
render 

end

private
def setup!
@corrige =options[:corrige]
end

My var, @corrige is null.

I'm on ruby 1.9.2, rails 3.1.1, apotomo 1.4

I suggest we remove this hook, and update apotomo tuto, with a before_filter.

Cause this works:

before_filter :setup!

def onglets

setup!
render 

end

private
def setup!
@corrige =options[:corrige]
end

@apotonick
Owner

The before_filter is a good idea. Anyway, I thought that the options hash is passed into the callback as an block argument?

@xrorox

I tryied a few debug, and i found something interesting. I have copyied self into the setup! method (called with after_initialize), and the options hash.

Debug on these 2 vars were strictly identicals. Seem than options is an instance of my widget objet, when i'm using after_initialize, instead of a hash.

@xrorox

Problem is in widget.rb:84. We have to use @options with after_initialize. When i'm using after_initialize, my setup! arg list have to match my widget call.

I guess cause of some errors i got while calling states, but i'm not sure. By the way great work in including apotomo Rspec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.