How to avoid repeating code in controller

Hi,
I created a calendar class and i now have a method which gives me a 1
day view with timeslots etc. now i want to re-use that code for
generating 2 and 5 day views. how can i re-use my code so i can make a
show_two_days class which uses the logic of the show_one_day class?

am i correct it can’t be done with helpers?

regards,

Remco

Remco Hh wrote:

Hi,
I created a calendar class and i now have a method which gives me a 1
day view with timeslots etc. now i want to re-use that code for
generating 2 and 5 day views. how can i re-use my code so i can make a
show_two_days class which uses the logic of the show_one_day class?

am i correct it can’t be done with helpers?

regards,

Remco

I dunno if I understand you but you might have a look to
render_component

If they’re in the same controller, one method can call another. If
not, put the shared method in application.rb and it becomes available
from every controller.

        - dan


Dan K. mailto:[email protected]
http://www.dankohn.com/ tel:+1-415-233-1000

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