I decided to try using sinatra for a small project
I started the other day. I normally work in rails
and host my personal projects on heroku
. Since rails 3 came out I have also gotten hooked on bundler. I could not find any single source that documented how to use all of these together nicely. Here is how I got it to work.
The gemfile is pretty basic, set a source for gems and include the sinatra gem.
This is the rackup config file which sets the app up to run in rack.
This is the sinatra file. Note that I defined a class (MyApp). This is very important because our config.ru needs the class as a handle for the 'run MyApp' call. An alternative would be to use "run Sinatra::Application" in your config.ru file.
class MyApp < Sinatra::Base
get '/' do
First make sure rack is installed, then run the following commands in the root folder and the app should be up and running locally.
Deploying to Heroku
Just run the following commands in the root folder and the app should be up and running on Heroku.
git add .
git commit -m 'Initial version of MyApp'
git push heroku master
It seems that the bundled gems are added to the load path without any explicit calls to Bundler. I have a Sinatra app running on Heroku, and my config.ru is simply:
I explicitly require each gem as needed in app.rb and it all works.
Using Bundler with Sinatra and deploying to Heroku is definately a great combination of technologies. I would also recommend checking out PadrinoRB (http://www.padrinorb.com/), a framework we built on top of Sinatra that augments it's functionality, gives you bundler support out of the box and a lot of other useful features like an admin interface.
Thanks for this. To get running locally I had to do:
bundle exec rackup
might help someone else who's stuck.
In fact, I had a problem using the method described in this post (ie require "bundler")
Errno::ENOENT - No such file or directory - /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/views/index.erb:
When I switched to simply:
Everything started working again.
There is a bug where you say `require './myapp'`, because that means you want to require it relative to the directory you are currently in, but you actually want to require it relative to the config.ru file (ie if you ran this from a different directory, it would break).
Instead, you can `require File.dirname(__FILE__) + "/myapp"` which will require from the directory of config.ru
Or you can edit the load path so the directory is in it, and then require like normal, relative to that dir:
`$LOAD_PATH.unshift(File.dirname(__FILE__)); require 'app'`
Alternatively, when you run your server, you could do `$ bundle exec rackup -I . config.ru` which adds the current dir (the dot, the relative path to the root of your app) to the LOAD_PATH when you start the app. I like this best, it keeps the code cleanest, and you can put it in a rake task so you don't have to type all that stuff out. The problem is that Herkou doesn't currently give you that kind of control (I think Celadon Cedar does allow you to specify this command, but haven't tried)
Anyway, good write up, thanks for sharing :)
nice article It changed into so best article used to be truly satisfied by means of seeing this article and we are also giving information about books thank sharing for useful information
Oracle Fusion procurement Online Training
Oracle Fusion cloud procurement Online Training
Wonderful blog. Thanks for sharing. I also recommend you to use this mspy phone tracker. Great software!
Very impressive and nice blog, Thanks for sharing your valuable info, it is very easy to understand, really more helpful for me.
Oracle DBA Training in velachery | Oracle DBA Training institute in velachery
غسيل خزانات بمكة افضل شركة غسيل خزانات بمكة
غسيل خزانات بجدة افضل شركة غسيل خزانات بجدة
غسيل خزانات بالدمام افضل شركة غسيل خزانات بالدمام
IEEE Final Year projects Project Center in Chennai are consistently sought after. Final Year Students Projects take a shot at them to improve their aptitudes, while specialists like the enjoyment in interfering with innovation. For experts, it's an alternate ball game through and through. Smaller than expected IEEE Final Year project centers ground for all fragments of CSE & IT engineers hoping to assemble. Final Year Project Domains for IT It gives you tips and rules that is progressively critical to consider while choosing any final year project point.
The Angular Training covers a wide range of topics including Components, project projects for cseAngular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training
Mua vé máy bay tại đại lý Aivivu, tham khảo
săn vé máy bay giá rẻ đi Mỹ
chuyến bay đưa công dân về nước
vé máy bay từ đức về việt nam
giá vé máy bay từ nga về việt nam
192.168.l.254.254 router login admin password informations. With http://192.168.1.254 ip address, you can perform many operations such as wifi password change, router configuration, Ip configuration, Iptv, port opening via this Ip.
Extraordinary post yet I was considering whether you could make genuinely seriously in regards to this matter? I'd be appreciative if you could explain truly further. slot online
Post a Comment