sinatra

Error happens when I read items in DataMapper

class List include DataMapper::Resource property :id, Serial property :name, String property :items, String end List.auto_migrate! get '/:id' do @list = List.all(:id => params[:id]) @items = @list.items erb :show end I get undefined method `it...

How to enable SSL for a standalone Sinatra app?

I want to write a quick server app in Sinatra. It has to be self-contained (i.e. not use apache/nginx/passenger) but also has to support SSL. Is there an easy way to enable SSL support for Sinatra (using WEBRick for example)? ...

Where does RACK log to ?

I am running a sinatra app through RACK. To which file does the activity get logged ? Also how can I set the log file path ? ...

How to serve generated images with sinatra in ruby

I wrote a simple Sinatra app that generate an image using rmagick from some user inputs. The image is saved in the ./public directory with a unique file name. The unique file name is used in the HTML generated by Sinatra so that each user gets the correct image. Once a day a script deletes files older than one hour. This is clearly a ter...

Heroku and Yahoo! Apps

Hi All, I have created an App on Heroku which works perfectly in a Web Browser. As a second step, I want to view the App hosted on Heroku in Yahoo! App. Its pretty simple to open any webpage in a Yahoo! App. One just need to mention the URL where the site is LIVE and rest is taken care by Yahoo! App. However, if I try to open the App h...

Call Sinatra erb from another class

I need to render a Sinatra erb template inside a class in my controller. I'm having issues calling this though. I've looked in the Sinatra rdocs and have come up with this: Sinatra::Templates.erb :template_to_render When I do this, I get the following error: undefined method `erb' for Sinatra::Templates:Module Is there a way to c...

Test with Rspec using session sinatra

Hi All, I have sinatra appliction using session, how do I test a page that uses session? I using Rspec + sinatra Tks ...

Multiple Haml Elements on Same Line

I want to be able to have two Haml elements on the same line. For example: %h1 %a{:href => '/'} Professio. That doesn't work. How would I get something like this to work without borking? ...

Serving static files with Sinatra

I have one page website only using HTML, CSS and JavaScript. I want to deploy the app to Heroku, but I cannot find a way to do it. I am now trying to make the app working with Sinatra. . |-- application.css |-- application.js |-- index.html |-- jquery.js `-- myapp.rb And the following is the content of myapp.rb. require 'rubygems' re...

Rails or Sinatra? which is good to start learning, for a php programmer?

I've been working far too long with php and getting bored with it. I also want to learn a new language. I've been using Ruby and like it. I've to decide between Rails and Sinatra, which one would you recommend? Is it true that Sinatra can't be used to build complex apps, and its only for simple apps? ...

Sinatra Routing Exceptions

I want to be able to do the following: get '/:slug' do haml :page end get '/administration' do haml :admin end Is there a way that I can have get '/:slug' do have an exception for /administration? I realize you can do this with if else statements: get '/:slug' do if params[:slug] == 'administration' haml :admin else ...

How to quickly learn Python and Ruby frameworks coming from a PHP background.

I've been using CakaPHP and Kohanaphp but now I want to try out other frameworks from a more sophisticated OOP language for my next projects. How can I learn the following frameworks quickly so I can immediately pick what to use: Pylons Sinatra Ramaze Tutorials and examples from online resources would really be great. For php deve...

Rack::Test not able to find web app cookie

While testing a Sinatra app with Cucumber, Rack::Test was not able to find the cookie that my app created, even though I could clearly see that it was in the Rack::Test::CookieJar object by dumping it with "p". ...

Help me understand dynamic layouts in Sinatra

Help me understand this; I'm learning Sinatra (and Rails for that matter, er, and Ruby). Say I'm doing a search app. The search form is laid out in one div, and the results will be laid out in another. The search form is rendered into the div by a previous view (maybe from a login form). I want to process the form params, perform the...

Auth problem on Facebook using Ruby/sinatra/frankie/facebooker

Hello guys, I'm using sinatra/frankie/facebooker to prototype something simple to test the facebook api, i'm using mmangino-facebooker the more recent version from github and I cloned the most recent version of frankie. I'm using sinatra 0.9.6. My main code is as simple as possible: before do ensure_application_is_installed_by_faceb...

Using Cucumber With Modular Sinatra Apps

I'm building out a medium-sized application using Sinatra and all was well when I had a single app.rb file and I followed Aslak's guidance up on Github: http://wiki.github.com/aslakhellesoy/cucumber/sinatra As the app grew a bit larger and the app.rb file started to bulge, I refactored out a lot of of the bits into "middleware" style m...

Can not access response.body inside after filter block in Sinatra 1.0

I'm struggling with a strange issue. According to http://github.com/sinatra/sinatra (secion Filters) a response object is available in after filter blocks in Sinatra 1.0. However the response.status is correctly accessible, I can not see non-empty response.body from my routes inside after filter. I have this rackup file: config.ru req...

What is the easiest way to get an embedded upload progress bar using Ruby/Sinatra/Haml/Passenger/nginx?

I have a website where people can upload 30+mb of data in a single block, and I want to be able to show them the progress of their upload without causing the web page to become unresponsive, similar to how flash uploads work in gmail. There's this question here, but I don't know if that progress bar is embedded in the page or if it's us...

Ruby, post and redirect

Hi! I have situation like this: user submits form with action='/pay' in '/pay' I have to add some additional parameters and send post request to www.paymentprovider.com/new_payment The problem is that I want to post and redirect (at the same time) user to this new website www.paymentprovider.com/new_payment. Currently I am using N...

Sinatra, JavaScript Cross-Domain Requests JSON

I run a REST-API build on top of Sinatra. Now I want to write a jQuery Script that fetches data from the API. Sinatra is told to response with JSON before do content_type :json end A simple Route looks like get '/posts' do Post.find.to_json end My jQuery script is a simple ajax-call $.ajax({ type: 'get', url: 'http://api....