How to get the current action & controller name in Rails
In your views: controller.action_name controller.controller_name In the controller itself, you can just call controller_name action_name If you want the current…
If an element is visible or hidden using jQuery
Usually you can trust the .toggle function (or .slideToggle) to hide or show whatever you want it to. But occasionally…
unsolved: jQuery: Can you redefine the click function on a button? (unsolved mystery)
I have defined a click function in the document ready $(“#submit_request_toggle”).click(function() { $(‘#submit_request’).slideToggle(500); }); Later, I do an ajax call…
jQuery function for slightly opaque images
Here’s a jQuery function to make your images slightly opaque (or “disabled” looking), then have them fade in when you…
How can I see my relative url root? (Rails)
The relative url root is the thing that is appended to the front of your path, but after the domain…
Ruby Strings
symbol what it does + concatenate “a” “b” => -1 >> “a” “a” => 0 >> “b” “a” => 1…
Execute shell script from within ruby
1) Use the “system” method system “ls” 2) Or use backticks. Note that backticks support you returning to the results…
Migration Generator Shortcuts
Some great shortcuts for script generation. I always try to start by building scaffold for any new entity, then remove…
Ruby function to check if something is a number
def is_a_number?(s) s.to_s.match(/\A[+-]?\d+?(\.\d+)?\Z/) == nil? false : true end
Rails Plugins with SVN
I’m working with a plugin that I wrote. I want to pull the plugin into an app I’m writing, but…