sinatra

Sinatra on Nginx configuration - what's wrong?

I followed this tutorial more or less... I installed the passenger gem, executed passenger-install-ginx-module, sucessfully installed nginx and inserted this into the config: server { listen 80; server_name localhost; root /home/admin/sintest/public; # <--- be sure to point to 'public'! passenger_enabled on; } In /home/admin...

How do I test this Sinatra Method?

Trivial Sinatra application: require 'rubygems' require 'sinatra/base' require 'haml' class InfoController < Sinatra::Base get "/" do haml :index end end And my test: describe InfoController do include Rack::Test::Methods def app InfoController end it "should return the index page when visiting the root of the ...

How to build my own rack preview like sinatra - staticmatic

Hi Guys I have HAML SASS converter and want to allow users the localhost:30000 functionality i guess to view their HAML SASS files in the browsers. Any guides you know that might help me? Thanks ...

Sinatra on Ruby 1.9.2-p0

Hello, I'm quite new to Ruby language (up to now I developed in Groovy + Grails) but since I was curious about it I wanted to try Sinatra on Ruby 1.9.2-p0. I have a trivial website that is contained in /mywebpage and has 2 files: # blog.rb get '/' do 'Hello World!' end get '/impossible' do haml :index end and #config.ru path = ...

Undefined method auto_upgrade! when pushing Sinatra/DataMapper app to Heroku

Does anybody know the magic incantation required to get a Sinatra application that uses DataMapper up and running on Heroku's Bamboo stack? The Bamboo stack doesn't include any pre-installed system gems and no matter what combination of gems I try I keep getting this error: undefined method `auto_upgrade!' for DataMapper:Module (NoMetho...

If i learn Sinatra or Padrino does that help me with Rails?

I assume that for all of these i need to get a better understanding of Ruby itself but does (say) Padrino translate directly into skills i would use in Rails or is it indirect. I am a PHP programmer but as i have used PHP frameworks which are clones of Rails i am finding it not too difficult ...

How can I run something in a thread with passenger?

Hello, I'm using Phusion Passenger with my nginx to deploy rails/sinatra applications, and I'm currently having a problem. I want to run a class that checks for new submissions to reddit.com every 30 seconds. But since passenger shuts down the application after x seconds of idle time, it won't keep checking. Yes, I've tried to set pass...

What is the best way to post contents of an ordered list on html form submission?

In the past I have always used a hidden field, and on the submit button onClick event I stuff the list contents (the text of the li elements) into a hidden form field using custom code, and parse it out on the server-side using custom code. This has always felt like a hack and I was wondering if there is a more modern approach. I'd lik...

Ruby Datamapper stored decimals displaying in scientific notation

I have a model, called delivery: property :id, Serial property :created_at, DateTime property :updated_at, DateTime property :price, BigDecimal, :precision => 10, :scale => 2 Delivery has a price, which when viewed in SQLite is values such as 5.49, 6.95, 4.95 When displaying this information in the output (coded in ...

Passenger Rack app 'cannot infer basepath'

I have a simple config.ru file for my Sinatra app. require 'sinatra' require 'app' run Sinatra::Application However, Passenger is failing with the error no such file to load -- app. I've tried using the 1.9 method require_relative but that now causes the error cannot infer basepath. I'm currently using the very hacky require File.jo...

Installing a gem from Github with Bundler

I am trying to use the instructions here to install a pre-released version of a gem with bundler. The "bundle install" output lists the gem as getting installed, but "gem list" fails to find it. My Gemfile: source :gemcutter gem 'sinatra', '1.1.0', :git => 'http://github.com/sinatra/sinatra.git' gem 'RedCloth', '4.2.3' Here is a g...

Is it possble include Nesta CMS into Rails3 application ?

I'd like "to mount" a Nesta CMS app onto a Rails3 app This should be possible couse of being Nesta a Sinatra app, which should be a Rack mountable layer, ... but how would you do it ? Where will you start from ? Does anybody has experiences on this topic ? Suggested docs ? thanks in advance luca ...

How can I selectively clear the cache for Sinatra + Nginx + Phusion Passenger?

I have a modular Sinatra app running on nginx with Phusion Passenger. When I alter my app (and in particular, some YAML files which are used to generate pages), I'd like to be able to clear only the parts of my cache that are affected (and leave evertyhing else in /public alone--I know I can just clean out the whole cache, but I was hop...

RSpec, no such file to load when loading helpers

I have a Sinatra app that uses RSpec2 beta 19. My application.rb and app_helpers.rb are in a directory /lib. The application obviously loads the helper module and my application runs but when I run RSpec I get an error that it is unable to located any gems required in the helper module. I am now sure how to load the application.rb withou...

return different value from a before do block in sinatra

is there a way to stop execution and return a different value in a before do block in sinatra ? before do # code is here # I would like to 'return "Message"' # I would like "/home" to not get called. end // rest of the code get '/home' do end ...

How to run a cron job in Heroku, with a Sinatra app

Hi there! I'm writing a tiny Sinatra app, and I want to host it on Heroku for simplicity sake. But, what I have is a task that scraps some sites and adds some data into my database every hour. Currently this is just written as a ruby script that needs to be executed. What Heroku has is a rake based cron job. Now if this was a rails ...

How to execute shell command in new window in ruby/rails?

I have a rails app that needs to start a supporting Sinatra web service. I would like to invoke it via a rake task. But I want the Sinatra app to start inside a new terminal (command) window. Yes, I need to see it executing. # rake task namespace :daq_controller do desc "start the DAQ contoller web service" task :start do dir =...

Writing a Sinatra Extension using options in routes

Lets say I'm writing a sinatra extension which mounts a second public directory at a given mount point. require 'sinatra' require 'sinatra/moar-public' set :moar_local, './downloads/' set :moar_remote, 'dls' I now expect a user going to http://myapp.com/downloads/thing.bin to be given the file at [sinatra_root]/dls/thing.bin. Writin...

Serving large static files with Sinatra

Sinatra can serve files from a static directory with the set :public, 'your_directory' command, but how can I replicate this in a new route? Importantly, this new route needs to respect byte ranges too! Any ideas? I feel like I should be able to leverage the already present code in the static serve part of sinatra. ...

How can I make Rack::Session::Pool work in a test using Sinatra and RSpec?

How can I make sessions work in my RSpec tests? I have tried something like this: describe "createnewlist_route_spec" do include Rack::Test::Methods use Rack::Session::Pool def app @app ||= Sinatra::Application end it "should save listitem to database" do post '/addnewlistitem', {:item => 'testitem'}, :sessions =>...