gem install ruby-debug (Ruby 1.8) or gem install debugger (Ruby 1.9) Start your server with script/server --debugger Set a breakpoint by invoking debugger anywhere in your code...
...path that crosses the breakpoint Once you reach the breakpoint, the page loading will seem to "hang". Switch to the shell you started the server with. That shell will be...
If you need to capture signatures on an IPad or similar device, you can use Thomas J Bradley's excellent Signature Pad plugin for jQuery. To implement, just follow the...
...steps on the Github page. The form If you have a model Signature with name: string, signature: text, you can use it with regular rails form like this:
...CSS but it does not fit fancy requirements. Here is a hack for the special case where you want to truncate one of two strings in one line that can...
...both vary in length, while fully keeping one of them. See this example screenshot where we never want to show an ellipsis for the distance: You can try pretty hard...
...have a useful blank? method. It returns true for nil but also for empty strings or empty arrays. There is also a universal method present? which returns true for all...
...may also use up.util.isBlank(). By default, this function returns true for: undefined null Empty strings Empty arrays A plain object without own enumerable properties All other arguments return false.
Microsoft Exchange service administrators can enable Exchange Web Services (EWS) which is a rather accessible XML API for interacting with Exchange. This allows you to read and send e-mails...
...meeting attendees, track responses, manage to-do tasks, check user availability and all other sorts of things that are usually only accessible from Outlook. You can implement an EWS by...
Sometimes, you may want to open up a second database connection, to a read slave or another database. When doing that, you must make sure you don't overwrite an...
...will actually cause all kinds of trouble: def with_other_database ActiveRecord::Base.establish_connection(slave_settings) yield ensure ActiveRecord::Base.establish_connection(master_settings) end Putting aside that you are setting...
Sometimes you need to monitor a connection from your machine to a specific, single host or network in order to identify which network hop between your machine and the target...
...causes trouble. You can use the following shell script to easily achieve this kind of monitoring. If the target host is unable to respond to the specified number of ICMP...
...did not happen yet you should use cap deploy:migrations. The problem Let's say that you have something like that in your config/deploy.rb to create a database dump every...
...called for cap deploy:migrations. The same applies to other things that are hooked similarly, like an after 'deploy', 'craken:install'. How to avoid it When looking at the default...
...are close to given coordinates you can use the Graticule gem. Graticule Graticule offers several methods to compute the distance between two geo-dated objects but fetching records from the...
...radius of a location is a bit trickier: def close_destinations(latitude, longitude) distance_sql = Graticule::Distance::Spherical.to_sql(:latitude => latitude, :longitude => longitude, :units => :kilometers) Destination.all(:conditions => [ "#{distance_sql...
When you click a link or a press a button on a Selenium-controlled browser, the call will return control to your test before the next page is loaded. This...
...can lead to concurrency issues when a Cucumber step involves a Selenium action and a Ruby call which both change the same resources. Take the following step which signs in...
Suggested Workflow Set the ruby version in .ruby-version to 2.3.5, then perform these steps one by one, fixing errors as they occur: Update gems as listed below, and bundle...
...Boot a Rails console - see below for a list of changes you will probably need Run Specs with --backtrace option Run Cucumber features (with Geordi's --debug option)
Geordi uses parallel_tests if available for running the test suite. To debug an application it is very unhandy to have multiple processes as your terminal I/O will not work...
...as expected once a breakpoint is hit. Even parallel_tests support an option to enable a single process run, it is not possible to pass this option through geordi. But...
...you create columns in a migration. Its meaning depends on the column type, and sometimes the supplied value. The documentation states that :limit sets the column length to the number...
...of characters for string and text columns, and to the number of bytes for binary and integer columns. Using it This is nice since you may want a bigint column...
Terminator has a cool feature that allows you to split your terminal into many panels and type in all of them at the same time. It's called broadcasting and...
...and could be very dangerous (e.g. if you're logged in to a production server in a terminal that is on another workspace). To prevent the broadcast from affecting other...
...in: days) to import, while I actually just wanted to have the full database structure with some data to use on my development machine. After trying several suggestions on how...
...to speed up slow MySQL dump imports (which did not result in any significant improvement), I chose to import just some rows per table to suffice my needs. Since editing...
We recently decided to put static content for HouseTrip.com to Amazon Cloudfront for a faster user experience. This happens fully automatically on deploy and is transparent in development. Together with...
...a heavy use of sprites this sped up page load time quite nicely. These are a couple of the problems you need to solve in order to do this:
If - for whatever reason - you have to render stylesheets dynamically, the following snippet might be of help. It emulates what "sprockets" would to when precompiling your assets, and give your...
...stylesheets access to all the regular bells and whistles (like asset_path, proper @imports etc): class DynamicStylesheetsController < ApplicationController def show logical_path = RELATIVE_PATH_TO_YOUR_TEMPLATE path = File.join(Rails.root...
You're better off using debugger-ruby_core_source: gem install debugger-ruby_core_source If you can't do this, try the following. Here is how to fix the...
...for a project using Ruby 1.9.3-p448 -- adjust accordingly for your project. Fetch the source for your Ruby version, if you do not yet have it: rvm fetch ruby...
...AWS CA file and copy it to the machine you want to connect from: http://s3.amazonaws.com/rds-downloads/mysql-ssl-ca-cert.pem As far as I could find out, you (currently) cannot access further details...
Try to connect using MySQL client % mysql -uyour_username -p -h rds_hostname_from_management_cockpit.eu-west-1.rds.amazonaws.com --ssl --ssl-ca=/path/to/mysql-ssl-ca-cert.pem Use this statement to check whether a secure connection is used:
Whenever Firefox updates, all your Cucumber features that use Selenium break. This is annoying. In order to remedy this, version 0.5.0 of our geordi gem comes with a script that...
After installation, you can setup a separate Firefox copy for Selenium like this: setup-firefox-for-selenium Once the setup process has completed, you have two Firefoxes: One...
Be careful when stubbing out attributes on records that are defined by associations. Nothing is as it seems to be. The associated record has its own universe of things; when...
...delegating calls to it, you ca not stub methods on the associated record and expect them to be around. That is a general issue with this pattern/approach. What's happening...
...to change the locale of your Postgres cluster. A popular one is your development system's locale being used by default (which may be annoying). Here is how to do...
Beware: By following the steps below, you will drop and recreate your cluster. You will lose all data (including roles). Instructions below include a procedure for dumping and restoring...
Create a directory .ssl in your home directory. Go there and create a self-signed certificate. It is important to enter localhost.ssl as Common Name when asked. This...
...action and :except => :some_unsafe_action as options. Boot thin thin start -p 3001 --ssl --ssl-key-file ~/.ssl/server.key --ssl-cert-file ~/.ssl/server.crt The option -p tells thin to bind...
...merge in the file named with %A by overwriting it, and exit with zero status if it managed to merge them cleanly, or non-zero if there were conflicts...