Inheritance in helpers? Or should I do it all in a completel

Hi there.

In the process of learning Rails I’m displaying data from my model in
an HTML table. The view template got really messy so I decided to
build a class to tidy things up and help me with the table generation.
I started out putting it in the controller. But then I thought that
the right place for it (following the MVC pattern and Rails
orthodoxy) would be in a view helper.

But it seems helpers doesn’t define classes but rather methods that
are mixed into to the view class. I stuck some classes in the helper
module and managed to instantiate objects from those classes in my
view but calling built in helper methods (like link_to) from my new
helper objects didn’t go so smoothly.

How am I to do inheritance with helpers? Should I use a hierarchy of
modules? Is that the Rails way of doing things?

alex

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs