sinatra

Sinatra / Rack fails with non-ascii characters in url

I am getting Encoding::UndefinedConversionError at /find/Wrocław "\xC5" from ASCII-8BIT to UTF-8 For some mysterious reason sinatra is passing the string as ASCII instead of UTF-8 as it should. I have found some kind of ugly workaround... I don't know why Rack assumes the encoding is ASCII-8BIT ... anyway, a way is to use string.forc...

Is it possible to make a sinatra application into a Rails engine?

I'm considering using Integrity as a continuous integration tool, but don't want to (or can't) set up a separate domain for the application. Is it possible to get a Sinatra app (like integrity), and make it a Rails Engine? How would one go about do it? EDIT: I realize that the "engines" normally require Rails code like controllers a...

Small web-framework like Sinatra, Ramaze etc in .NET

Are there any similar frameworks like Sinatra, Ramaze etc in .NET? I'm in theory after a framework that let's me create an entire webapp with just one classfile (conceptually) like Sinatra. I'm going to use it for something work-internal, where ASP.NET MVC is too "big" (and I get confused by it's usage) and I have WebForms up to my ear...

How do you run tests in Sinatra ?

I have no idea how to test my Sinatra application. Do I just run ruby That does not seem to work. All files out there only talk about how to write the contents of the file, but not about how to get it running. Thanks ...

How do I exclude a path from requiring basic auth in Sinatra

I'm writing a smallish web service in Ruby using Sinatra. Access to pretty much everything is controlled using http basic auth (over https in production). There is one particular directory that I want to exclude from requiring authorization. Is there an easy way to do this? ...

Contact form in ruby, sinatra, and haml

I'm new to all three, and I'm trying to write a simple contact form for a website. The code I have come up with is below, but I know there are some fundamental problems with it (due to my inexperience with sinatra). Any help at getting this working would be appreciated, I can't seem to figure out/find the documentation for this sort of...

Mongomapper query collection problem

When I define the User has_many meetings, it automatically creates a "user_id" key/value pair to relate to the User collections. Except I can't run any mongo_mapper finds using this value, without it returning nil or []. Meeting.first(:user_id => "1234") Meeting.all(:user_id => "1234") Meeting.find(:user_id => "1234") All return nil....

Rails - render :action to target anchor tag?

I'm looking to use render like so: render :action => 'page#form' I also tried this: render :template => 'site/page#form' That didn't work either. The form on this particular page is at the very bottom, and if any errors occur on submission I'd hate for the user to be defaulted to the top of the page. I also need to use render (not ...

What do you use Sinatra for?

Im confused about Sinatra (the ruby framework). Is it a lightweight Rails replacement or you can have them running side by side? Can you do a web application (as in Rails)? For example a twitter clone? ...

Real Life examples of Sinatra applications

Im getting interested in Sinatra to develop micro web applications. I'm not sure where to draw the line when choosing between Sinatra and Rails. Please can you provide some real life examples of applications in Sinatra in the web? ...

Sinatra style web framework for Erlang

Hi, I programmed in Ruby and Rails for quite a long time, and then I fell in love with the simplicity of the Sinatra framework which allowed me to build one page web applications. Is there a web framework like Sinatra available for Erlang? I tried Erlyweb but it seems far too heavyweight ...

Embed webserver in desktop app: wxRuby and Sinatra

I would love to give my windows based desktop applications a web interface and vice versa. My desktop application is written in wxRuby and the webserver is Sinatra (using webrick). The simplest idea was just to mash them together, this does not work. This code does not work. The webserver and gui app do not run simultaneously. The...

Multiple Block Parameters with Sinatra

I'm trying to get this Sinatra GET request to work: get '/:year/:month/:day/:slug' do end I know you can get one param to work with block parameters: get '/:param' do |param| "Here it is: #{param}." end But how can I use multiple block parameters with the first code block? I'm open to other methods. ...

Sinatra enable :sessions not working on passenger/apache

Hi guys, Am having trouble getting enable :sessions to persist for a simple Sinatra app hosted on passenger/apache. I'm storing the state of session[:authorized] in a cookie. It works locally when hosted on Rack::Handler::Mongrel but I can't seem to get same behaviour on passenger. I've tried two methods for enabling sessions, both of ...

Should I be using Rails or Ruby for this website application? How?

Hi all, I'm very new to web programming (or actually, very old to it, since the last time I messed with the web was HTML 1.1), but now need to deploy a web application quickly. It seems like every time I turn around, there's new acronyms and technologies to learn (JSON, XMLRPC, GWT, Javascript, Rails, etc). Here's what my app must do:...

Sinatra on Passenger always fails on first attempt

I have a small Sinatra app I'm running on a shared hosting account using Passenger. However, the first time the app is accessed after a while, I get a Passenger error page saying the application could not be started. Usually because Sinatra could not be found. I am assuming this is just a normal delay from when a new instance is spawned...

Access Ruby accessors using block variables

I have an application that I am using Active Record to access a database. I'm trying to take the information and put it into a hash for later use. Here is basically what I am doing. require 'active_support' @emailhash = Hash.new emails = Email.find(:all) emails.each do |email| email.attributes.keys.each do |@co...

How do I hmtl_escape text data in a sinatra app?

I have a small Sinatra app which generates html fragments for me from an ERB template. How do I html_escape the output? The <%=h somestring %> helper does not exist in Sinatra. ...

Ruby / Sinatra / HAML flash message problem

I have the following small Sinatra application (I've removed the extra unneeded code): helpers do def flash(args={}) session[:flash] = args end def flash_now(args={}) @flash = args end end before do @flash = session[:flash] || {} session[:flash] = nil end post '/post' do client = Twitte...

How do I get an array of check boxes in haml?

Hi, I have an array of strings, called @theModels, in a routine implemented as part of a Sinatra server. These models are options for the user to select, and are obtained by the back end (the idea being, as new models are added, then the front end code should not change). I'm using haml to render html. How can I enumerate each eleme...