Using jQuery and Prototype Javascript Together with jQuery.noConflict();
To use the jQuery javascript framework in a Rails application, that also uses the Prototype framework for the same application, you'll need to reassign the $() function for jQuery to another variable. This is very simple to do. Just make sure to include t...
Written by Sean Behan on 06/17/2012
A Ruby Regex for Removing Links and Images from Text
r = /https?:\/\/[\S]+/i
you_string.gsub(r, '')
Here's the rubular regex to play around with yourself http://rubular.com/r/SRKkYrW4IJ
Written by Sean Behan on 11/14/2013
Gem Information with Gem List
If you want to get version information about a gem the easiest way to do it is with this command
gem list
For example
gem list activemerchant
will output the activemerchant versions I have installed. You can pass only part of the name like
gem list ...
Written by Sean Behan on 06/17/2012
Rails Send_File in Production Delivers an Empty File
If you're running Rails in production it will by default be configured to let apache or nginx send files for you. If you're handling file downloads yourself with send_file
send_file("path/to/file.txt")
you will notice that the downloaded files are empty...
Written by Sean Behan on 06/17/2012
How to Merge a YAML File Into a Single Hash in Ruby
require 'yaml'
# Nested YAML structure from something-nested.yml
#
# nested:
# key: value
# key_two: value_two
# Procedural Approach to building a single Hash from nested YAML data structure.
@yaml = YAML.load_file("something-nested...
Written by Sean Behan on 06/17/2012