Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sinatra helper in external file

Tags:

sinatra

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

like image 493
equivalent8 Avatar asked Aug 02 '11 18:08

equivalent8


1 Answers

The simple and recommended way:

module ApplicationHelper

# methods

end

class Main < Sinatra::Base

  helpers ApplicationHelper

end
like image 72
kgpdeveloper Avatar answered Sep 22 '22 19:09

kgpdeveloper