sinatra

Deploying Sinatra app on Dreamhost/Passenger with custom gems

隐身守侯 提交于 2019-12-05 22:42:51
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/sinatra/lib/sinatra' set :run, false set :environment, :production set :views, "views" require 'public/myapp.rb' run Sinatra::Application I have already done gem install pony and gem unpack pony (into vendor/). Afterwards, I tried adding require 'vendor/sinatra

Heroku and Datamapper problems

一笑奈何 提交于 2019-12-05 21:19:27
I can launch a basic app on Heroku, displaying a message with get '/'... works just fine. However, whenever I try to add sqlite with datamapper, the thing breaks down. In order to see my app structure, check out the project on github . I've kept the code pretty bare-bones. In the log from heroku I'm getting: 2011-06-26T21:28:36+00:00 app[web.1]: /app/.bundle/gems/ruby/1.9.1/gems/dm-core-1.1.0/lib/dm-core/adapters.rb:163:in `require': no such file to load -- dm-postgres-adapter (LoadError) The thing about this is that I'm not using postgres, so I'm confused why it is saying this. "The thing

implement a rails before_filter in ruby without rails

六眼飞鱼酱① 提交于 2019-12-05 21:18:13
问题 I am using g a logger in all of my classes. I want each msg to begin with class name and method name like so: Class_name::Method_name this is what i'm doing now : class FOO def initialize end def bar msg_prefix = "#{self.class}::#{__method__}" ... some code ... @logeer = "#{msg_prefix} msg ..." end def bar2 msg_prefix = "#{self.class}::#{__method__}" ... some code 2 ... @logeer = "#{msg_prefix} msg2 ..." end end i want to use a before_filter like in rails to prevent duplicity, I am using

Test with Rspec using session sinatra

我们两清 提交于 2019-12-05 21:07:33
I have sinatra appliction using session, how do I test a page that uses session? I using Rspec + sinatra Tks This page , show's the main problem of testing session with rspec and sinatra . The main problem is that the variable session is not accessible from the test code. To solve it, it suggests (and I confirm) to add the fowling lines at spec/spec_helper.rb : def session last_request.env['rack.session'] end It will make accessible a mocked session object from the last request at the test code. Here's my controller code that read's a code param and stores its value at session : post '

Sinatra and Chartkick Example

◇◆丶佛笑我妖孽 提交于 2019-12-05 18:19:37
I am quite new to Ruby as web platform and learn best by adapting and expanding examples. I like Sinatra and want to use it and Chartkick to display charts. Unfortunately, I'm having trouble getting even the most trivial example running and there seems to be a dearth of full examples (lots of 'one liners'). Here's what I have: require 'sinatra' require 'chartkick' get '/' do '<%= javascript_include_tag "//www.google.com/jsapi", "chartkick" %> <%= pie_chart({"Football" => 10, "Basketball" => 5}) %>' end So what devastatingly simple thing am I doing wrong? Any help would be greatly appreciated.

How do I access Sinatra's Logger outside the Request Scope

╄→尐↘猪︶ㄣ 提交于 2019-12-05 17:08:05
问题 It seems that Sinatra's logger is only available inside request handlers (See https://github.com/sinatra/sinatra#logging), but what if I want to use a logger in other places, for example in helper methods or in the configure hook? Is the Sinatra logger available through other means? 回答1: The docs give some examples on scope, but you can see the logger helper within methods defined in the helper block, as the helper block has Application scope. Within configure it's not available, but what I

Loading Stylesheets in Sinatra

与世无争的帅哥 提交于 2019-12-05 16:50:33
问题 I'm using Sinatra, and I've been trying to load in some stylesheets. I've tried just the normal html link tag in my erb, but that hasn't worked. ive tried <head> <link href="style.css" rel="stylesheet" type="text/css" /> </head> It's not an issue with the url i'm using, is there some special way of achieving this? 回答1: When you use href="style.css" , you’re specifying a relative link to the stylesheet. The actual path that your browser will request will depend on the url of the current page,

“Heroku push rejected, no Cedar-supported app detected” when trying to upload a Sinatra app with an existing git repo

对着背影说爱祢 提交于 2019-12-05 15:55:15
I have an existing git repo for my personal website, which I am porting to Sinatra (mainly for templating, it's a static site). I do NOT want to lose/reset this git repository. When I try to push to Heroku, I get the error below. I have a config.ru file, a Gemfile, and a Gemfile.lock, along with some other stuff for Sinatra. Running rackup works, running bundle exec rackup works, and I didn't get any warnings from Heroku about missing dependencies. Am I missing something? I can post the directory structure of my site if it would help (though it's close sourced). ~/Repos/website ➜ gp heroku

Sinatra-like web-framework for Pharo Smalltalk [closed]

佐手、 提交于 2019-12-05 15:18:39
Is there a Sinatra -like web-framework for Pharo? Or can the Zinc-HTTP-components do that more or less out-of-the-box? Thanks! Depending on your exact needs, Seaside-REST might also be interesting . I have been kindly pointed to Ratpack by Tim Felgentreff http://ss3.gemstone.com/ss/RatPack.html He also has a github repository, probably with more up-to-date code: https://github.com/timfel/ratpack 来源: https://stackoverflow.com/questions/13674859/sinatra-like-web-framework-for-pharo-smalltalk

Running Sinatra on port 80

[亡魂溺海] 提交于 2019-12-05 11:27:44
问题 I installed Sinatra and it works but it uses port 4567 by default. I want it to run on port 80. In an effort to get it to work on port 80, I tried this: require 'rubygems' require 'rack/handler/webrick' require 'sinatra' Sinatra::Application.default_options.merge!( :run => false, :env => :production, :port => 80 ) get '/' do "Hello World" end But I get this error: $ ruby -rubygems index.rb index.rb:5:in `<main>': undefined method `default_options' for Sinatra::Application:Class (NoMethodError