zeroclipboard.js in some of our projects but now we switched to
clipboard.js because it does not rely on flash. Flash support of the major browsers has ended.
Some more advantages of clipboard.js:
Subject: performance on smartphones and tablets
I just used your framework in one project and must say,
I am really pleased with it – but only on a desktop computer.
Have you benchm…
Starting from Rails 4.0, you can use a special form options helper called
#collection_check_boxes. It behaves similar to
#collection_select, but instead of a single select field it renders a checkbox and a label for each item in the collection.
= form_for @post do |form| = form.collection_check_boxes :author_ids, Author.all, :id, :name_with_initial
How generated form params look like ———————————…
You may browse a formatted and hyperlinked version of this file at https://unpoly.com/changes.
This is a major update with some breaking changes.
up.elementhelpers to complement native
Elementmethods. You might not even miss jQuery anymore.
Carrierwave includes some handy helper methods you can use to resize your images. Here is a quick summary of them, if you need more details read the docs. You can also use all command line options from RMagick directly if these helpers are not good enough for you.
Capybara will fail to find
<a> tags that are missing an
An example would be an AngularJS application where the following HTML actually works. 
Capybara will fail to find that link, even though looking it up via the DOM shows it:
>> find_link("Hello") Capybara::ElementNotFound: Unable to find link "Hello" >> find("a").text => "Hello"
Spammers have started abusing other application to send their spam. This works like this:
In Rails 3+, you can use:
class Project delegate :url_helpers, to: 'Rails.application.routes' def project_path url_helpers.project_path(self) end end
For Rails 2, use the attached Modularity trait. It will give any Ruby class a method
#url_writer, on which you can call URL helpers:
class Foo does 'write_urls' def self.class_method url_writer.session_path end def instance_method url_writer.project_path(5) end end
sort method doesn't work as expected with German umlauts:
["Schwertner", "Schöler"].sort => ["Schwertner", "Schöler"] # you probably expected ["Schöler", "Schwertner"]
Also numbers in strings will be sorted character by character which you probably don't want:
["1", "2", "11"].sort # => ["1", "11", "2"] # you probably expected ["1", "2", "11"]
Also the sorting is case sensitive:
["a", "B"].sort # => ["B", "a"] # yo...
You can use mail-tester.com to check your application's e-mails for issues that might cause e-mails to be classified as spam.
They provide a one-time e-mail addresses that you can use to sign up etc. You can then check for scoring results of SpamAssassin and other potential issues.
You don't need to hit 10/10. Something around 9/10 is perfectly fine.
When building an application that sends e-mails to users, you want to avoid those e-mails from being classified as spam. Most obvious scoring issues will not be relevant to you because you are not a spammer.
However, your application must do one thing by itself: When sending HTML e-mails, you should include a plain-text body or tools like SpamAssassin will apply a significant score penalty. Here is how to do that automatically.
HTML elements with
overflow-y: auto or
overflow-y: scroll will get a scrollbar when their content is higher than their own height.
When you scroll an element , the element's
scrollTop property is updated with the scrollbar's new position. You can also set
element.scrollTop = 30 to scroll the element to a vertical pixel position counted from the top.
The browser's main document viewport is also scrollable by default. The element that …
This card tries to summarize by example the different uses of heredoc.
strip_heredoc should be used for a text, where you want to preserve newlines. (multi-line -> multi-line)
squish should be used for a text, where you want to squish newlines. (multi-line -> one-line)
def foo bar = <<~TEXT line1 line2 line3 TEXT puts bar.inspect end foo => "line1\nline2\nline3\n"
Read more: [Unindent HEREDOCs in Ruby 2.3](/makan…
In order to save the original value of a constant, set the new value and restore the old value after a scenario was completed, you can use the following helper. It takes care of saving the old constant value, setting the new one without throwing warnings and resets the value with an
This module also enables you to introduce new global constants.
Since these newly defined constants do not have any value to be reset to,
they simply are deleted (
remove_const) once the respective Cucumber step finishes.
You can copy the file at…
Set the ruby version in
.ruby-version to 2.3.5, then perform these steps one by one, fixing errors as they occur:
1) Update gems as listed below, and bundle
2) Boot a Rails console - see below for a list of changes you will probably need
3) Run Specs with
4) Run Cucumber features (with Geordi's
5) When all tests are green, look through your Gemfile and remove as many version constraints as possible.
6) Boot the application in different environements to spot further issues, e…
Imagine you have 2 HTML boxes. The first one has a
margin-bottom of let's say
30px and the second one a
20px. After rules of collapsing margins have been applied we have a margin of
50px) between these two boxes (see this article for an illustration) . This is because no addition of both margins takes place but the maximu…
Using uncountable resources is not recommended as it breaks Rails' magic, e.g. when using
form_for. You'll always be better off using simple pluralizable resources.
Rails automatically creates path names for routes defined via the
resource method. When you put
resource 'user' into
config/routes.rb, you can call
users_path and get the path to the
index action in the
However, if you have an uncountable resource like
Sheep, you cannot access the index action via
sheep_path, because it will…