...calls html_safe if you're not escaping. FWIW, an HTML string may easily become invalid when truncated, e.g. when a closing tag gets chopped off. However, when the input...

When making cross-domain AJAX requests with jQuery (using CORS or xdomain or similar), you will run into issues with...

On your local system that only hosts non-critical development data and only you have access to, you can store...

...new value (be aware that you should use a secure and salted hash) or better call the the_user_to_log_out.reset_remember_token! method that does the things for you.

Rails comes with grouped_collection_select that appears to be useful, but isn't. As an alternative, consider the flat...

makandra dev

Note that you should disable the Java plug-in in your browsers after installation. Ubuntu >= 12.04 Java 11

CoffeeScript and JavaScript (ECMAScript) both have operators in and of. Each language use them for more than one purpose. There...

Spreewald's patiently repeats the given block again and again until it either passes or times out.

When you have many changes, and you want to spread them across different commits, here is a way to stage...

...polymorphic association. class Event < ApplicationRecord has_many :letters, as: :record end class Letter < ApplicationRecord belongs_to :record, polymorphic: true end event = Event.new.letters.build event.save! # => ActiveRecord::RecordInvalid: Validation failed: Record must exist...

makandra dev

If you need to run a program on a remote machine (e.g. to your office PC) with a graphical UI...

If you use transactional_fixtures or the database_cleaner gem with strategy :transaction, after_commit callbacks will not be fired...

...member', :home_page end It has some limitations: Only works for singular member references ("belongs to"), not for a collection of references ("has many") No support for deletion (but could...

makandra dev

This is an awesome gadget in your toolbox, even if your test coverage is great. gem install ruby-debug (Ruby...

If you migrate a Rails application from Sprockets to Webpack(er), you can either transpile your CoffeeScript files to JavaScript...

web.archive.org

When flagging a spec that will be implemented later as pending, include a failing spec body or RSpec 3 will...

...what "memoize" in earlier rails versions did. There is a gem that reintroduces this behavior, but this is the essential implementation. Remember In the above example, some_expensive_calculation is...

...it will be fixed, I guess it will be for Rails 4 only. The best workaround right now is to lock your version of rack at version...

makandra dev

...remember to nilify it afterwards. Otherwise other examples will see your global changes. A better way is to use the .with_power method to change the current power for the...

After updating Rubygems you see a wall of deprecation warnings like this: NOTE: Gem::SourceIndex#add_spec is deprecated, use...

ImageMagick can automatically crop surrounding transparent pixels from an image: convert input.png -trim +repage output.png

blog.cloudflare.com

Two weeks ago, Cloudflare was struck by a global outage that lasted ~30 minutes. The incident was rooted on a...

...skipping asset compilation when assets have not changed? Turns out there is an even better way to speed up Capistrano deployments with asset compilation – and it's even simpler.

...On the database level, you will see these queries (simplified; the number at the beginning of each line is the connection ID): 1 Connect 1 BEGIN 1 INSERT INTO foos...

...you might be doing stuff afterwards that could require to abort the transaction). A better approach As a general rule, never use ActiveRecord::Base.establish_connection and also don't use...