Simple sinatra app:
require 'rubygems'
require 'sinatra'
get '/' do
"Hey"
end
Then:
$ ruby test.rb
And when I hit http://localhost:4567, it drops the connection and I get:
/usr/local/lib/ruby/gems/1.8/gems/thin-1.2.5/lib/thin_parser.bundle: dlopen(/usr/local/lib/ruby/gems/1.8/gems/thin-1.2.5/lib/thin_parser.bundle, 9): no suita...
I am currently struggling with stubbing out a helper method of my Sinatra app from within Cucumber.
I have a Sinatra app with simple session authentication (by cookies) and I want to turn of authentication by stubbing out the logged_in? helper method for my Cucumber scenarios.
There seems to be a problem with Sinatra and Cucumber conce...
I don't know if this is a ruby question or a Sinatra question, because I'm new to both. The following code does not work, and I understand why, because the first my_variable is local to its block. I just don't know the syntax for getting it right.
require 'rubygems'
require 'sinatra'
configure do
my_variable = "world"
end
get '/...
I've got a Sinatra app that I'm trying to run on Dreamhost that makes use of pony to send email. In order to get the application up and running at the very beginning (before adding pony), I had to gem unpack rack and gem unpack sinatra into the vendor/ directory, so this was my config.ru:
require 'vendor/rack/lib/rack'
require 'vendor/s...
Sinatra app:
require "rubygems"
require "sinatra"
get '/' do
"Hello world. It's #{Time.now} at the server!"
end
windows XP with latest version of mongrel, sinatra, shotgun. ruby 1.8.6
running shotgun test_app.rb results in
C:\Files\sites\sinatra>shotgun test.rb
== Shotgun starting Rack::Handler::Mongrel on localhost:9393
Th...
I am writing a small Sinatra-based app and would like each view to be able to insert various items into the layout, for example the page title or extra CSS/javascript references in the head.
Currently my layout (erb) looks like this (simplified):
<html>
<head>
<title>Hard Coded Title Here</title>
<link rel="stylesheet" ... />
<...
I'm wanting to do a lightweight push-style HTTP response in my existing Sinatra web app. Is there any mechanism that allows me to not respond to an HTTP request and keep the connection open until I wake up the connection at a future time?
...
I wrote a teeny tiny Sinatra app that runs fine, locally, but for some reason as soon as I put it online, all I get is 'Internal Server Error'.
How do I get the logging output?
I'm running on Dreamhost with passenger, using the instructions from the Sinatra book.
So I added to more handlers:
get '/hello/:name' do
"Hello, #{params[:...
Let's say an application has really specific data which belongs to a user, and nobody is supposed to see it except the owner. I use MySQL database with DataMapper ORM mapper. The application is written in Ruby on Sinatra.
Application behavior:
User signs up for an account. Creates username and password.
Logs into his dashboard.
Some ...
On production my application runs in a virtual directory
eg /virt/action
get '/action'
...
end
I want to have the /virt also when running sinatra in development mode, is there a way to do that?
...
I'm creating a small app in Sinatra, and I'd like to determine my users' cities from their zip code (which they would input), the distance between them and other users' (by zip code), and possibly a heat map of the zips.
How would I do this? I've tried the geoip gem, but it doesn't seem to do what I want. Would I use an external servi...
In Sinatra, if you have a "GET /images/photo1.jpg" request... you can save a lot of time by making a "public" directory. Any route not found is assumed to be inside your "public" directory.
However this seems to work just for GET requests. Is there a way to do something similar for POST requests?
Either:
Turning on some static method...
Hi all,
So I'm trying to figure out a way of stubbing a controller method in rspec for a Sinatra app. The main reason for this is to test the logical flow of the application and to make sure it calls the necessary functions when certain conditions are met. So, in essence, I want to be able to do something like
controller.should_receive...
I am using Rack:Session:Pool for memory based sessions. I would like
to access the pool instance variables that is contacted in
Rack:Session:Pool so I can see all the active session and contained data. How can I do
that from within Sinatra or on the irb prompt.
my initial thought was ::Sinatra:Application::Rack::Session:Pool, but
that s...
I couldn't find resources on how to use authlogic with sinatra. Or at least no documentation about a canonical way to do authentication with authlogic ...
Anyone has pointers to some tutorials, sample code or can sketch out a minimal authlogic/sinatra example?
Thanks in advance.
...
I've set up Rack::Reload according to this thread
# config.ru
require 'rubygems'
require 'sinatra'
set :environment, :development
require 'app'
run Sinatra::Application
# app.rb
class Sinatra::Reloader < Rack::Reloader
def safe_load(file, mtime, stderr = $stderr)
if file == Sinatra::Application.app_file
::Sinatra::Appli...
I'm trying to set up custom Pingdom monitoring of my Rails application and would like to craft an XML response that looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<pingdom_http_custom_check>
<status>OK</status>
<response_time>210.22</response_time>
</pingdom_http_custom_check>
Where the response_time value is the time tak...
I am trying to identify a user ID number, to grab a Student row from an ActiveRecord table, but for some reason the 'post' block won't find my :id.
For the 'get', the url is localhost:9456/update/17. It's this 17 I need to pass to the 'post' block to update the database.
I am not sure how to do this. Parse the URL? It seems like I am m...
I have a Sinatra app that serves pages as read-only or editable depending on if the user is logged in.
The controller sets a variable @can_edit, that is used by the views to hide/show edit links. How can I test @can_edit's value in my tests? I have no idea how to get at the current instance of the controller under Rack::Test.
I use cl...
Hi Guys I run a sinatra application with mongomapper. I have models called Movie(Document) and Cover(EmbeddedDocument).I embed covers into movies using
@movie.covers << @cover
@movie.save
This works great.
when hit @movies.covers I got the array of embedded documents.
But I am not able to destroy the embedded document. I tried someth...