has_one :note end class Note < ActiveRecord::Base belongs_to :project end Now say we need a validation that ensures that a description is set (validates_presence_of :description...
...within Note but only if the Project has a flag called external set to true. The following code will lead to some problems as the associated object is not present...
When you have a complex recipe setup with multistage deployment you may run into this error: `role_list_from': unknown role `something' (ArgumentError) Consider this task definition: namespace :foo do...
...task :bar, :roles => :something do # do crazy stuff end end Whenever we call foo.bar in our recipe, Capistrano will fail if you deploy to a stage where none of the...
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...
If you're using Paperclip to store and convert images attached to your models, processing a lot of images will probably cause headache for your system operation colleagues because CPU...
If you're on Unix you can use nice to tell the Kernel scheduler to prefer other processes that request CPU cycles. Keep in mind that this will not...
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...
...using form_for you can give the form's target URL either as a string or an array: form_for(admin_user_path(@user)) do...
# same as:
...path and polymorphic_url If you would like to generate a path or URL string from an array of route components just as form_for does, you can use polymorphic...
...restangular collection and you want to remove an element from it, after you've successfully deleted it from the server. The README suggests to say something like $scope.users = _.without($scope.users...
...horribly when you want to use restangular's attributes on that collection. This is simply because of the way _.without works: It returns a new array with all elements except...
...assignable_values does not invalidate a record even when an attribute value becomes unassignable. See this example about songs: class Song < ActiveRecord::Base belongs_to :artist belongs_to :record_label...
We'll create two record labels with one artist each and create a song for one artist. When we change the song's record label, its artist is still...
...with Xfce's sometimes arcane configuration UI, this can be a huge time waster and super-annoying if you need to get work done the same day. This card describes...
...how to setup a classic panel layout as you might be used to from Gnome 2 or Windows (see screenshot below). You can use this to quickly get productive in...
...a gem and you have a Gemfile in your project directory, you might be surprised that your gem dependencies aren't already required in your specs. Here is some info...
That also means that if you have an embedded Rails app in your spec folder (like has_defaults), and you boot its environment, it should call Bundler.require for you...
...modify (e.g. add 2px) a Sass variable that defines multiple values as one (e.g. for short-hand CSS definitions such ass padding), you can by using nth. It's ugly...
...While you could split up such variables into multiple values (e.g. combined padding into one for vertical and one for horizontal padding) in your own Sass definitions, when using some...
...a Pull Request on GitHub that includes commits from another Pull Request, you will still see them after the "child" PR has been merged. Unfortunately, GitHub won't automatically update...
Check out the target branch git checkout my-target-branch Make sure you are up to date against origin (e.g. git fetch and git status). You should...
...Its behavior differs from the default JSON.dump or to_json behavior in that it serializes Ruby symbols as ":symbol", and that it doesn't like an ActiveSupport::HasWithIndifferentAccess.
...want it to replace #to_json (but you can always just call Oj.dump explicitely). Security warning: Oj does not escape HTML entities in JSON Be aware that Oj.dump is not...
When you're writing specs for ActiveRecord models that use memoization, a simple #reload will not do: it 'updates on changes' do subject.seat_counts = [5] subject.seat_total.should == 5 # seat_total is...
...either memoized itself, or using some # private memoized method subject.seat_counts = [5, 1] subject.seat_total.reload.should == 6 # => Still 5 end You might be tempted to manually unmemoize any memoized internal method to...
Note that if you plan to downgrade Firefox because your Selenium tests broke after a Firefox upgrade, there is a better way that doesn't involve downgrading. Mozilla has stated...
...that they will no longer provide security patches for any but the most recent versions of Firefox. So running an old Firefox should not be a long-term solution for...
Sometimes, the IRB prints a warning during boot: irb: warn: can't alias source from irb_source. Explanation
...the IRB creates many aliases to give the user quick access to irb functions like source-ing a file. However, if IRB's context already responds to the alias it...
The Capybara API is somewhat hard for parse for a list of methods you can call on a Capybara node. Below you can find such a list. It's all...
...credit goes to the Capybara committers. When you talk to Capybara from a Cucumber step definition, you always have page as the document root node, or whatever you scoped to...
...useful if, for example, you want to use a background-image that has to scale with the width and the div should only have the height of the picture.
.outer { width: 100%; background-image: image-url('background.png'); background-size: cover; } .inner { padding-top: 60%; } How does it work? There are several CSS attributes that can handle values as...
...Rails project that has been lying around for some time (git pull, bundle install, migrate) security-update: prepare and finish a security update by pulling/pushing/merging and deploying just as our...
...console staging shell: open a shell on a Capistrano target, optionally selecting the server with --select-server tests: run all employed tests; checks for: Cucumber, RSpec, Test::Unit and rake...
ChromeDriver clicking works by simulating a mouse click in the middle of the element's first client rect (or bounding client rect if it doesn't have a first client...
Another element which is now located at this position receives the click A step which finds and clicks the desired link via javascript may solve the problem:
Install FreeBSD Download a suitable image from this site Select File > New… to and follow the instructions, choose the .iso file you downloaded as image file Start the new virtual...
...and extract the VMWare tools cd /tmp tar zxpf /cdrom/vmware-freebsd-tools.tar.gz umount /cdrom # run installation script, # just confirm the default answers when asked cd vmware-tools-distrib/ ./vmware-install.pl Set screen resolution...
Use the following command to test if a server (in this example: makandra.com on port 443) uses Perfect Forward Secrecy (PFS): openssl s_client -connect makandra.com:443 -cipher ECDHE-RSA-RC4...
You should see something like the following: ~ > openssl s_client -connect projecthero.com:443 -cipher ECDHE-RSA-RC4-SHA CONNECTED(00000003) depth=1 O = AlphaSSL, CN = AlphaSSL CA - G2
Google Calendar integration into Thunderbird suddenly did not work any more for me. Thunderbird kept asking me for my password to access calendars, but did not show them when given...
Remove the Ubuntu packages the "Lightning" and "Google Calendar Provider" Thunderbird addons: ^ sudo apt-get remove xul-ext-gdata-provider xul-ext-lightning Restart Thunderbird Install the addons...
The following solution will delete files on a volume. If you don't know exactly what you're doing, you can run into big trouble with...
I play mp3 files on my car stereo that are stored on a SD-Card. When I've copied those mp3 files to the FAT formatted SD-Card...