ruby on rails - RoR: defining a class inside a view helper file -


i have view helper file, app/helpers/analysis_helper.rb, toplevel methods i've been using in various view files. works fine. defined analysissummary class inside analysis_helper.rb package view-specific functionality.

however, when try instantiate analysissummary in view file, error:

uninitialized constant actionview::compiledtemplates::analysissummary 

perhaps rails telling me shouldn't defining class inside helper file? if so, suggest parking analysissummary? it's not controller, it's not model...

thanks.

why need class? why not collection of methods? that's helper is: collection of helpful methods. business logic not belong in helpers. can place code in module within helper file if want give more structure , organization, though.

you can put classes in app/models without having activerecord class, should consider purpose of class before place there.

if concerns rendering view, , not accessing data directly, belongs in view or view helper.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -