Tag: Rails

Rails, Capistrano, Database.yml

I’ve found the easiest way to manage the config/database.yml file in a Rails + Capistrano configuration is to add the following line to your capistrano config/deploy.rb configuration file: set :linked_files, %w{config/database.yml} Then add config/database.yml to your .gitignore file. After which, add your environment’s database.yml file to the appropriate location on the remote server(s): #{deploy_to}/appname/shared/config/database.yml Where […]

Capistrano, rbenv, upstart, and -su: bundle: command not found

If you’re running into the following error attempting to deploy via Capistrano with rbenv, foreman, and upstart: -su: bundle: command not found Then, be sure to take the export and eval rbenv statements in your ~/.bashrc file and copy them to the bottom of your ~/.profile export PATH=”$HOME/.rbenv/bin:$PATH” eval “$(rbenv init -)”   As this […]

Rails, Paperclip, Custom Interpolation

To allow custom interpolations in the PaperClip :path designation, add the following to your config/initializers/paperclip.rb file: Paperclip.interpolates :custom_field do |attachment, style| attachment.instance.custom_field end   Where :custom_field is whatever field associated with your attachment model you’d like interpolated in your path.

Resolve Net::HTTPBadResponse: wrong status line

In Ruby/Rails, if you’re running into the following error: Net::HTTPBadResponse: wrong status line When attempting to post data to a secure (https) url, with something similar to: Net::HTTP::post_form(“https://www.example.com”,{})   Then you can rewrite your request to avoid the exception like this: url = URI.parse(“https://www.example.com”) http = Net::HTTP.new(url.host,url.port) http.use_ssl = true request = Net::HTTP::Post.new(url.path,{}) request = […]

Rails remote multipart form with remotipart bind ajax:success

Rails 3.x / 4.0 does not handle remote multipart forms natively, so a workaround is needed. To get remote multipart forms working correctly you can use the following steps (quick solution). First: Add the remotipart gem to your GemFile gem ‘remotipart’, ‘~> 1.2.1’ Then, Update your javascript manifest file (in basic configurations this is usually […]