after_initialize bug #45

Open
xrorox opened this Issue Oct 17, 2011 · 3 comments

Comments

Projects
None yet
2 participants
@xrorox

xrorox commented Oct 17, 2011

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

This comment has been minimized.

Show comment
Hide comment
@apotonick

apotonick Oct 19, 2011

Owner

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

Owner

apotonick commented Oct 19, 2011

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

@xrorox

This comment has been minimized.

Show comment
Hide comment
@xrorox

xrorox Oct 20, 2011

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 commented Oct 20, 2011

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

This comment has been minimized.

Show comment
Hide comment
@xrorox

xrorox Oct 21, 2011

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.

xrorox commented Oct 21, 2011

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