esilver
esilver

Reputation: 28473

How do I write an extension for Sinatra without packaging it as a gem?

I want to include the distance_of_time_in_words method in a sinatra app

I don't want to package and distribute a gem, which is what the Sintra docs direct you to do. I just want that method accessible in my view.

What's the easiest way to do this? Thanks.

Upvotes: 2

Views: 301

Answers (2)

Konstantin Haase
Konstantin Haase

Reputation: 25964

Just place the file somewhere in your ruby load path ($LOAD_PATH) and require it. Or place the code directly in your app file.

Upvotes: 0

Shtirlic
Shtirlic

Reputation: 692

On http://www.sinatrarb.com/intro.html look at Helpers section and define helper methods for use in route handlers and templates

Upvotes: 4

Related Questions