Whenever you create a table from a database migration, remember to add
created_at timestamps to that table. Without those timestamps, investigating future bug reports will be hell. Always have timestamps.
When you create a table using
create_table, you can add timestamps by using the
class CreateEpisode < ActiveRecord::Migration
create_table :episodes do |t|
An alternative to this technique is using VCR. VCR allows you to record and replay real HTTP responses, saving you the effort to stub out request/response cycles in close details. If your tests do require close inspection of requests and responses, Webmock is still the way.
If applied, this commit will your subject line here
It might sound trivial, but there is no such thing as a "hover" or "mouseover" state on touch devices. If your application is supposed to work on iPads, smartphones, etc., don't hide information behind a tooltip, and don't make controls appear when hovering over another element.
Generally, things that happen/appear when you hover an element should do the same when you click the element.
This card compares patterns to store trees in a relation database like MySQL or PostgreSQL. Implementation examples are for the ActiveRecord ORM used with Ruby on Rails, but the techniques can be implemented in any language or framework.
We will be using this example tree (from the acts_as_nested_set docs):
+– Child 1
| +– Child 1.1
| +– Child 1.2
The parallel-gem is quite easy to use and can speed up rendering time if you want to render the same partial multiple times (e.g. for rendering long lists of things).
If your parallelized code talks to the database, you should ensure not to leak database connections.
Consider you want to render a list of groups with their members as json. You can use a partial for the rendering of group members, b…
To avoid this, add the attached code to your cucumber's
/features/support directory. It will disable AJAX requests at the end of the scenario and wait for outstanding requests to complete.
Requires spreewald and only works for requests triggered by jQuery.
These steps are now part of Spreewald.
This note describes a Cucumber step that lets you write this:
Then I should see a table with the following rows: | Bruce Wayne | Employee | 1972 | | Harleen Quinzel | HR | 1982 | | Alfred Pennyworth | Engineering | 1943 |
If there are additional columns or rows in the table that are not explicitely expected, the step won't complain. It does however expect the rows to be ordered as stat…
In modern default RSpec configurations, your tests are usually run in random order. This helps to detect "flickering" tests that only fail when run in a certain order.
The reason for this are tests that have side effects causing other tests to fail later. The hard part is to find the offending test.
Randomized with seed 12345. Take a note of the number….
Around will not happen until after a feature's
Background has been processed. Use
After to avoid that.
Consider this Cucumber feature file:
Feature: Something that needs to be tested Background: Given a user And I sign in Scenario: Sign out When I sign out Then I should see "Signed out" Scenario: Something else # ...
Now, assume you have these step definitions:
Around do puts "** Around: before yield" ...
Solved with flexbox is a collection of css problems which were hard or impossible to solve without flexbox:
Spreewald was updated to version 1.9.0 and does not wrap steps that use
Assuming you're wanting to undo the effects of
git rm or
rm followed by
git add -A or something similar:
This restores the file status in the index:
git reset -- <file>
then check out a copy from the index
git checkout -- <file>
git add , the first line above suffices, assuming you haven't committed yet.
Make sure to use double dashes
-- to tell git to checkout a file instead of a branch. This only is relevant for [files having the same name as a branch](https://git-scm.com/docs/git-ch…
When working with ActiveType you will often find it useful to cast an ActiveRecord instance to its extended
Starting with active_type 0.4.0 you can use
ActiveType.cast for this:
class User < ActiveRecord::Base ... end class SignUp < ActiveType::Record[User] ... end user = User.find(1) sign_up = ActiveType.cast(user, SignUp) sign_up.is_a?(SignUp) # => true
This is basically like [
awesome_print in the console while it is not in
require 'awesome_print' => LoadError: cannot load such file -- awesome_print
gem install 'awesome_print'
$: << `/home/xxx/.rvm/rubies/ruby-x.x.x/lib/ruby/x.x.x/gems/awesome_print-x.x.x/lib` require 'awesome_print' => true
Note: To find out the path quickly just look at
$: to get the base path of your ruby dir and then append the gem with version of the output of
Adding the gem to the developme…
Sometimes you want git to ignore certain files that appear on your machine. You can do this in 3 ways:
While it might be tempting to set it per project (other devs might benefit from it), you
.gitignorefile with stuff…
RubyMine provides a visual tool for resolving merge conflicts locally.
Git > Resolve Conflicts
in the context menu to open RubyMine's merge conflict tool.
You can also use a similar pane view to compare to files.
Mark two files and press
Ctrl + D to compare.
Luckily, this is simple. Just install three packages:
sudo apt install ipheth-utils libimobiledevice-dev libimobiledevice-utils
Then turn on the "Personal Hotspot" in iPhone settings, connect it to your Ubuntu machine via USB and you should be up and running.