sinatra

Padrino with mysql, rake fails.

I just wanna give a try on the new frame Padrino. I followed the steps given here. I am stuck at running the rake tasks. I used Mysql as my database. I created the project using the command. padrino g project sample_blog -t shoulda -e haml -c sass -s jquery -d activerecord -a mysql padrino g admin I have all the dependencies in orde...

How do I work with checkboxes with DataMapper and Sinatra?

I'm trying to make a simple room management service. The rooms have these properties: class Room include DataMapper::Resource validates_is_unique :number property :id, Serial property :number, Integer property :guest, String property :status, Enum[ :free, :occupied ], :default => :free end Then I create a new room like th...

Package Sinatra app into a single JAR file?

Hi everyone, I've an apparently (silly) simple question: With JRuby is it possible to deploy a single file Sinatra application? I mean: I've my Sinatra app with all needed gems exploded into some ./vendor/lib directory and I'd like to deploy the whole app as a single jar file to run on a deployment machine: $ java jar my_app.jar whe...

Heroku Postgresql error

I deployed an app that uses ActiveRecord to Heroku, and I got an internal server error. It works fine on my local machine (where the database is SQLite). Below is the log message for the error. The newsletters table is just a table with no associations. It's got just one field for email addresses. I don't know PostgreSQL, and I'm not sur...

Custom Subdomains in Sinatra app

I want my Sinatra app to allow users to create an account and access it via a subdomain (i.e. your-account.myapp.com). I found this to extract subdomains (http://gist.github.com/55784#file_subdomains.rb) but I'm having a hard time implementing it. Any ideas? I have an Account model (datamapper) with a field called account name, whic...

how to stop sinatra from running?

If ruby myapp.rb starts sinatra previewing at localhost:4567, how can I programatically stop/halt/kill it? Terminal command (other than Ctrl-C), or Rake tasks would be fine. I need to incorporate this into a Rake task or terminal. Thanks ...

Ideas to extend this little project? - A pidgin web ui

I have built a little Web UI for Pidgin(respectively all libpurple based messengers) together with DBus and Sinatra. It was for fun and learning purposes and now I'm looking for ideas to extend it. Can you think of any useful applications or extensions for it? Since I work on this project to learn something new, ideas for other techno...

Sinatra HTTP 'PUT' method

Something's wrong with the PUT action here, the form gets processed but the updated field is not being saved. I've did what Sinatra users are doing, by adding in "_method" for Sinatra to recognise that's its a HTTP PUT action. Could anyone spot any mistake here? # edit get '/entries/*/:id/edit' do @entry = Entries.get(params[:id]) ...

ruby 1.9 + sinatra incompatible character encodings: ASCII-8BIT and UTF-8

I'm trying to migrate a sinatra application to ruby 1.9 I'm using sinatra 1.0, rack 1.2.0 and erb templates when I start sinatra it works but when I request the web page from the browser I get this error: Encoding::CompatibilityError at / incompatible character encodings: ASCII-8BIT and UTF-8 all .rb files has this header: #!/usr/b...

Making a calendar with Sinatra

Well I don't actually want to make a calendar but I need a view for each day of the year which I guess is sort of the same. Say I have a view where you see e.g. "July 1st" in the top of the page and you have links to the day before and the day after. Beneath this there is a list of - in my example - rooms and they have different states -...

Is it a bad idea to create worker threads in a server process?

Hello, My server process is basically an API that responds to REST requests. Some of these requests are for starting long running tasks. Is it a bad idea to do something like this? get "/crawl_the_web" do Thread.new do Crawler.new # this will take many many days to complete end end get "/status" do "going well" # this can...

Capistrano asks for password when deploying, despite SSH keys

My ssh keys are definitely set up correctly, as I'm never prompted for the password when using ssh. But capistrano still asks for a password when deploying with cap deploy. It doesn't ask for the password when I setup with cap deploy:setup though, strangely enough. It would make the deployment cycle so much smoother without a password pr...

Sinatra and Datamapper - inserting data to a one to many relationship table

I have the following. Each article has a title and a body and also up to three urls. I would want to store the urls in a different table. Therefore in my form, i've a field for the urls. However they are not working, only the article fields get entered into the database. how should i specify them? Could any kind soul help me out with thi...

How do I test Sinatra helpers from irb?

I am trying to call a helper method in my Sinatra application from irb in order to test its output. I know I can get a console using this tip, and I've tried racksh as well. But if I do a "defined? my_helper" I always get nil. There must be some simple way of getting at those helpers. I have a feeling that this means digging through the ...

Rack::Session::Pool with Sinatra

I have a Sinatra webapp I've built using enable :sessions where I access my session data with session[:mything]. I now want to store data on the server side (ie. with database based sessions) and I can't figure out how to use Rack::Session::Pool, which appears to be the thing I need to use. How do I o about converting my webapp for use...

Sinatra can't serve JavaScript files without help? Is this correct?

Ok, so I'm not having trouble with this per say, but I want to make sure that I'm doing this right because it just seems like a lot of extra work in the long run. I am working with Sinatra and using HAML templates. I want to include a JavaScript file from my HAML file. My directory structure looks like this: media/ js/ init.js (file...

How to setup a Sinatra app under Apache with Passenger?

Let's say I have the simplest single-file Sinatra app. The hello world on their homepage will do. I want to run it under Apache with Phusion Passenger, AKA mod_rails. What directory structure do I need? What do I have to put on the vhost conf file? I understand I need a rackup file. What goes in it and why? ...

How can I secure my OAUTH secret in Phusion Passenger Sinatra app?

I have an app that uses a single-user OAUTH token. I can store the four values (consumer key/secret, token/secret) directly inside the app but that's not recommended and I don't want the secrets to be checked into source code. The app doesn't use a database. I know that however I store them, someone with access to the server could figure...

alias url with sinatra / padrino

I've this and it works get :about, :map => '/about_us' do render :erb, "<%= 'foo' %>" end get '/:slug' do redirect "/about_us" # <-- end Is possible to do in some way "render" instead of "redirect"? or something like render 'posts/1' ...

Sinatra and Bundler

Hi, I'm trying to get Bundler setup so I can deploy my Sintra a server with all the correct gems. I've created my Gemfile source :gemcutter gem 'sinatra', '1.0' gem "nokogiri", "1.4.2" gem "rack", "1.1.0" gem "dm-core", "1.0.0" gem "dm-migrations", "1.0.0" gem "dm-sqlite-adapter", "1.0.0" gem "pony", "1.0" Next I created a Confi...