sinatra

OpenSSL::SSL::SSLError - SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed:

只谈情不闲聊 提交于 2019-12-13 04:07:02
问题 I deployed a Facebook app using Heroku and got it partially working locally. I can see my app but I as soon as I click on connect with Facebook I get an Internal Server Error Message. This is what Foreman is throwing: OpenSSL::SSL::SSLError - SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed: Everything works on Production but I need to get local working to start integrating Mongo and FB. I followed all the instructions on: https://devcenter

Building Rack Middleware responses with Flash message functionality

房东的猫 提交于 2019-12-13 02:24:46
问题 I have a Sinatra app that's mounted on a Rails app under /admin . The Sinatra app is an admin dashboard, and therefore should only be available to authorized users. To enforce that, I built a piece of Rack Middleware that will run before the Sinatra app is called. The logic is simple - If user is authenticated, continue as normal If user is not authenticated, redirect to the root path with a flash alert message (I'm using the rack-flash gem to allow access to the flash messages in Rack) Code

How can I test multistep forms with Capybara & Minitest?

て烟熏妆下的殇ゞ 提交于 2019-12-13 02:24:43
问题 I have a single page Sinatra app that has a multistep form/wizard interface. If I want to test the form with Capybara, will need to repeat all the steps for each test? I'm hoping to avoid something like this: it "visits the home page" do vist "/" page.should have_content('foo') end it "clicks the first button" do vist "/" page.should have_content('foo') button_click("Next") end it "clicks the second button" do vist "/" page.should have_content('foo') button_click("Next") page.should_have

How to handle cookies when testing with Webrat?

▼魔方 西西 提交于 2019-12-13 01:27:06
问题 I'm writing Cucumber tests for a Sinatra based application using Webrat. For some tests I need to implement a scenario like Given I am logged in as admin When I am visiting "/" Then I should see "Settings" I define steps like this: Given /^I am logged in as "(.+)"$/ do |user| visit "/login" fill_in "login", :with => user fill_in "password", :with => "123456" click_button "Login" end When /^I am viewing "(.+)"$/ do |url| visit(url) end Then /^I should see "(.+)"$/ do |text| response_body

Ruby sort the multidimensional array via their key

南楼画角 提交于 2019-12-13 00:23:09
问题 I want to sort an array to sort in ascending or descending order. My array contains hash keys and the values I want to sort are float, integer and string (names). Names can be alphabetic or alphanumeric. I want to create a method that would handle all the sortings. It will take array, column name and sort order and return the rest of the array sorted. The following is the JSON output. My array contains the hash keys. [ { "sid": "101", "snumber": "798798", "name": "Anita 1", "time": 1800,

TypeError - no implicit conversion of nil into String Sinatra

落爺英雄遲暮 提交于 2019-12-12 16:28:18
问题 My code looks like this.. It is to upload the json data into a db after extracting the fields into a hash. But i get 'TypeError - no implicit conversion of nil into String' in line JSON.parse(json_data) of log_extractor.rb upload_results.erb: $( "form" ).submit(function( event ){ var fileoutput = reader.result; //$("#upload_button").click(function(){ $.ajax({ url:'/file_upload', type : "POST", data: { fileoutputid: fileoutput }, dataType: 'json', success: function(response) { }, failure:

Deploying a Rails app to a sub-URI with Passenger and Nginx?

若如初见. 提交于 2019-12-12 15:31:13
问题 I am already deployed my Rails app with Passenger and Nginx and it's working fine. Below is my servier configuration: server { listen 80; server_name localhost; location / { root /var/www/demo/public; passenger_enabled on; rails_env production; } Now I want to deploy a second app to a sub URI. Here the documentation is a little unclear. Could anyone please suggest me what will be the next configuration? Below is the configuration I am using for my second (Sinatra) application: location /log {

Enabling SSL for a thin server and sinatra

混江龙づ霸主 提交于 2019-12-12 14:31:48
问题 I'm trying to enable SSL for my thin server web app so that it can work over HTTPS. I have done the following:- launching of thin web server MyApp.run! :host => '127.0.0.1', :port => 9090, :sslenable => true, :sslverifyclient => OpenSSL::SSL::VERIFY_NONE, :sslcertificate => '.ssl/server_key.pem', :sslprivatekey => '.ssl/key.pem' I generated a self signed certificate and private key using the openssl module in Ruby, created a directory called .ssl and stored them there as pem files. The web

Call Sinatra delete route with jQuery

拟墨画扇 提交于 2019-12-12 14:31:28
问题 I am pretty new to Sinatra and am making a simple todo app that utilizes basic CRUD functionality. In the backend I have working routes and have tested everything. I wanted to incorporate some front end functionality and decided to use jQuery to help with that. I have a current piece of code in jQuery that adds a css class to one of the todo items when that item is clicked. I wanted to include a button that says "Delete completed tasks" that would collect the tasks with the class of

Before filter on condition

眉间皱痕 提交于 2019-12-12 10:17:37
问题 I have a Sinatra app where all routes require a user login by default. Something like this: before do env['warden'].authenticate! end get :index do render :index end Now I would like to use a custom Sinatra condition to make exceptions, but I cannot find a way to read if the condition is true/false/nil def self.public(enable) condition { if enable puts 'yes' else puts 'no' end } end before do # unless public? env['warden'].authenticate! end get :index do render :index end get :foo, :public =>