sinatra helper in external file

equivalent8 picture equivalent8 · Aug 2, 2011 · Viewed 9.4k times · Source

I have lot of helpers in my main Sinatra project_name.rb and I want to remove them to the external file, what is the best practice to do that ?

from ./preject_name.rb

   helpers do
     ...#bunch of helpers
   end

to for exapmple ./helpers/something.rb

thank you

Answer

kgpdeveloper picture kgpdeveloper · Mar 31, 2013

The simple and recommended way:

module ApplicationHelper

# methods

end

class Main < Sinatra::Base

  helpers ApplicationHelper

end