Updated: Helpers to render (money) amounts
- The
amount
helper now retrieves the decimal separator from your I18n dictionary (number.format.separator
) instead of hardcoding it to a comma. -
money_amount
helper tunnels options toamount
- New
money_amount
option:zero_as_dash
Related cards:
Helpers to render (money) amounts
When rendering a number, you want to pretty up the string coming from #to_s
:
- Render
0.0
as0
- Sometimes require a minimum number of digits after the decimal separator
- Change the decimal separator from
.
to,
in some European countr...
Customize tokenization of the MySQL FULLTEXT parser
The way MySQL's FULLTEXT tokenizer splits text into word tokens might not always be what you need. E.g. it splits a word at period characters.
Since the tokenizer has near-zero configuration options (minimum word length and stopwords list), you n...
Invoices: How to properly round and calculate totals
While it might seem trivial to implement an invoice that sums up items and shows net, gross and vat totals, it actually involves a lot of rules and caveats. It is very easy to create invoices where numbers don't add up and a few cents are missing....
How to use Haml in your helpers
You know those helper methods that just render some HTML but look weird because of content_tag
s all over the place? You could also use Haml instead.
Example
Consider the following helper.
def greeting
message = ''.html_safe
...
How to make Rational#to_s return strings without denominator 1 again
The way Rational#to_s
works on Ruby has changed from Ruby 1.9 on. Here is how to get the old behavior back.
You may want this for things where Rationals are being used, like when subtracting Date
objects from one another.
What's happening?...
Updated: Unobtrusive jQuery to toggle visibility with selects and checkboxes
Now works with radio buttons.
How to use Parallel to speed up building the same html partial multiple times (for different data)
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 da...
When sessions, cookies and Clearance tokens expire and how to change it
Expiration of Rails sessions
By default Rails sessions expire when the user closes her browser window.
To change this edit your config/initializers/session_store.rb
like this:
ActionController::Base.session = ...
Story Checklist Template
This is an story checklist I use to work on stories. For this purpose I extracted several cards related to the makandra process and ported them into a check list...
Guide to localizing a Rails application
Localizing a non-trivial application can be a huge undertaking. This card will give you an overview over the many components that are affected.
When you are asked to give an estimate for the effort involved, go through the list below and check wh...