sinatra

Can't access Docker's exposed port in Ubuntu

允我心安 提交于 2019-12-22 11:35:13
问题 The Sinatra web app I created works inside the container and I am able to access it at 9393 within the container. Following is my Dockerfile (which uses the image specified by the Dockerfile : jikkujose/red): FROM jikkujose/red MAINTAINER Jikku Jose <jikkujose@gmail.com> COPY . /banana_app WORKDIR /banana_app RUN bundle install EXPOSE 9393 ENTRYPOINT ["bundle", "exec", "shotgun"] I launched the built image by, docker run -itdP hey When I do, docker ps -a : CONTAINER ID IMAGE COMMAND CREATED

DataMapper - Single Table Inheritance

房东的猫 提交于 2019-12-22 11:33:21
问题 Could Some one please explain to me what is going on here? This is an example that I put together to show y'all whats up: class Person include DataMapper::Resource property :id, Serial property :type, Discriminator property :name, String property :age, Integer end class Male < Person end class Father < Male property :job, String end class Son < Male end class Female < Person end class Mother < Female property :favorite_song, String end class Daughter < Female end DataMapper.auto_upgrade! If I

DataMapper - Single Table Inheritance

☆樱花仙子☆ 提交于 2019-12-22 11:32:44
问题 Could Some one please explain to me what is going on here? This is an example that I put together to show y'all whats up: class Person include DataMapper::Resource property :id, Serial property :type, Discriminator property :name, String property :age, Integer end class Male < Person end class Father < Male property :job, String end class Son < Male end class Female < Person end class Mother < Female property :favorite_song, String end class Daughter < Female end DataMapper.auto_upgrade! If I

How to know what exceptions to rescue?

試著忘記壹切 提交于 2019-12-22 10:55:37
问题 I often find myself without knowing what exceptions to rescue when using a specific library of code in Ruby. For instance, I often use HTTParty for any HTTP requests my rails/sinatra app would make. I dug around the code for HTTParty and found a file containing the defined exceptions used. Great! I'll just rescue them when making a request. To test it out, I put in a bogus domain name for the request, but instead of HTTParty::ResponseError exception I expected, I instead get got a SocketError

Deploying Sinatra app on Dreamhost/Passenger with custom gems

冷暖自知 提交于 2019-12-22 10:48:24
问题 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

omniauth behind proxy

回眸只為那壹抹淺笑 提交于 2019-12-22 09:39:11
问题 I have a small app using omniauth and I'm testing it with LinkedIn provider (omniauth-linkedin). Unfortunately my test environment is behind a proxy. So I need to access linkedin through a proxy. How do I set the proxy address so the request to linkedin will succeed? It does not seem to be obeying the http_proxy settings. 回答1: I figured it out, I think.. ue OmniAuth::Builder do provider :linkedin, "KEY", "SECRET", {:client_options => { :proxy =>\ ENV["HTTP_PROXY"] || ENV["http_proxy"] }} end

Sinatra and Chartkick Example

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-22 08:56:08
问题 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

How to change the log level in Sinatra

梦想与她 提交于 2019-12-22 05:28:25
问题 I am using this code to enable logging in my Sinatra app: log_file = File.new('my_log_file.log', "a") $stdout.reopen(log_file) $stderr.reopen(log_file) $stdout.sync=true $stderr.sync=true The actual logging is done using: logger.debug("Starting call. Params = #{params.inspect}") It turns out that only INFO or higher level log messages are logged and DEBUG messages are not logged. I am looking for a way to set up the log level to DEBUG. 回答1: I guess there might be a better way, but you can

Neat way to conditionally test whether to add a class in HAML template [duplicate]

 ̄綄美尐妖づ 提交于 2019-12-22 05:17:15
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Append class if condition is true in Haml (with Rails) I'm using a template that allows you to mark a list item as current (using class=current ), highlighting it in a nav bar. In HAML, this looks like: %li.current Menu item A %li Menu item B %li Menu item C I have this code in a Sinatra view and want to programmatically add the class=current , depending on a parameter to the view. How do I do this in the

Displaying Error Message with Sinatra

独自空忆成欢 提交于 2019-12-22 05:07:57
问题 I'm writing a simple app that takes standard input from the user. As for the email entry, I have it verify if it is in a standard email format and then have it list the problems like this when a new instance is going to be saved: u = User.new u.email = params[:email] u.save if u.save redirect '/' else u.errors.each do |e| puts e end end I know that if it is correct it should return back to the home page. If it is wrong I want it to return to the home page as well, but I want it to return an