padrino

Padrino app with REST API

戏子无情 提交于 2020-01-06 13:02:47
问题 Within a Padrino application I have a posts controller with the conventional routes: Blog::App.controllers :posts do get :index do ... end get :show, :with => :id do ... end end This gives me therefore the normal URL access within the posts namespace http://blog.dev/posts http://blog.dev/posts/show/1 Now I want to provide access through a REST API from a different route outside the namespace , like for example: http://blog.dev/api/v1/post/all http://blog.dev/api/v1/post/1 How can I define the

ActiveRecord returns data in ASCII-8Bit Under Ruby 1.9.2-rc1

ⅰ亾dé卋堺 提交于 2020-01-02 04:11:15
问题 Further to the title, when loading data from ActiveRecord the encoding is always set to ASCII-8Bit in spite of my best efforts to force the encoding. I have entered as much detail as possible here to try and build a good error report someone could use to help me out! The project is using the following technologies: Padrino Framework Ruby 1.9.2-rc2 (Also 1.9.1 and 1.9.2-preview3) ActiveRecord MySQL (Full List) $ bundle show | ack '(record|padrino)' * activerecord (2.3.8) * padrino (0.9.14) *

How do I automatically generate static HTML from HAML with Sinatra or Padrino?

梦想的初衷 提交于 2019-12-25 08:15:55
问题 I want to serve static HTML pages using nginx . Then, I will use jQuery to update DIVs, SPANs, etc via AJAX calls from a Padrino server. I like creating my web pages in HAML because it's easier but in production, I don't want to serve HAML templates. Just raw, HTML at the speed of nginx. Is there an easy way to do this? What would be ideal would be a service that automatically renders HAML, partials, etc into the public folder that nginx could serve. 回答1: Simple, add padrino-cache to your app

Ruby - no PID found in tmp/pids/thin.pid (Thin::PidFileNotFound)

随声附和 提交于 2019-12-23 16:25:17
问题 I'm trying to start thin for my app but then the pid cannot be generated: $ thin -C /var/www/project_path/current/config/myproject.testing.yml start Now I can't stop it because there is no pid: $ thin -C /var/www/project_path/current/config/myproject.testing.yml stop /home/usr/.rvm/gems/ruby-1.9.2-p180@api/gems/thin-1.5.1/lib/thin/daemonizing.rb:131:in `send_signal': Can't stop process, no PID found in tmp/pids/thin.pid (Thin::PidFileNotFound) This is the yml file: pid: /home/usr/htdocs

SocketError at / getaddrinfo: nodename nor servname provided, or not known padrino

馋奶兔 提交于 2019-12-21 20:58:15
问题 I am trying to use padrino to build a dashboard for my amazon environment. But when I try the following piece of code in the controller: get :index, :map => "/" do AWS.config(access_key_id: 'ACCESS_KEY', secret_access_key: 'secret_access_key', region: 'ap-southeast-2') ec2 = AWS::EC2.new response = ec2.client.describe_instances(:instance_ids => ['instance_id']) @instance = response[:reservation_set].first[:instances_set].first render 'index' end I got the following errors: SocketError -

How to access a gemified Padrino Apps Model from outside (not in controller, but e.g. a standalone script)

空扰寡人 提交于 2019-12-13 05:19:22
问题 I have a Padrino App called Gusy that specifies (Sequel) Models like # gusy/models/seminar.rb class Seminar < Sequel::Model # hopefully irrelevant stuff defined here end I want to access this Model from either a second gem, or a script in bin/ . Now, e.g. I require Gusy from a second gem "gusy_fill". The Gemfile is put up to set the path to a Gusy git repository. I can successfullly see the Gusy namespace (and e.g. print the apps Version Gusy::VERSION ) if interactively exploring with bundle

configuring heroku database connection in padrino - DATABASE_URL fails

风流意气都作罢 提交于 2019-12-11 07:11:36
问题 I had a problem getting a padrino (0.11.2) application to run today on heroku. The errors I was getting back suggested that the connection URL wasnt working, e.g. 2013-06-20T12:55:59.040527+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/dm-core-1.2.1/lib/dm-core/adapters.rb:12:in `new': +options+ should be Hash or Addressable::URI or String, but was NilClass (ArgumentError) But I wracked my brains and couldnt see what the problem was until I read this article (https://devcenter.heroku

Carrierwave + Mongoid + gridfs + Padrino admin image upload

爷,独闯天下 提交于 2019-12-11 02:49:44
问题 i'm trying to get carrierwave + mongoid + gridfs to work for uploading images via padrino admin and then showing on front-end. at a loss as to glue everything. can someone help? following https://blog.engineyard.com/2011/a-gentle-introduction-to-carrierwave/ and https://github.com/carrierwaveuploader/carrierwave-mongoid. trying to persist an "Artwork" with an image upload returns: NoMethodError at /admin/artworks/update/53a0eedcf2c7961066000002 undefined method ` bson_dump ' for # file: hash

Uninitialized constant while trying to include helper module

旧城冷巷雨未停 提交于 2019-12-11 01:12:32
问题 The module that I am trying to include is located here: test/unit/helpers/test_helpers.rb Looks like: module TestHelpers end I am trying to include it in: test/unit/app/models/abc.rb class Abc < ActiveSupport::TestCase include TestHelpers end gives the following error: Error executing test/unit/app/models/abc.rb uninitialized constant Abc::TestHelpers Any ideas why this might be happening? 回答1: To include a module into your class, you need to require that file. require 'test_helpers' Add this

How to upgrade ruby version in Amazon Linux system?

馋奶兔 提交于 2019-12-10 03:31:23
问题 I have developed ruby application using padrino ruby framework. And I would like to deploy it on Amazon. I used this image. Amazon Linux AMI 2017.09.1 (HVM), SSD Volume Type And image description was: "The Amazon Linux AMI is an EBS-backed, AWS-supported image. The default image includes AWS command line tools, Python, Ruby, Perl, and Java. The repositories include Docker, PHP, MySQL, PostgreSQL, and other packages." After launching instance, I tested ruby version and it was ruby 2.0.0p648