makandra dev

The Rails asset pipeline improves delivery of application assets (javascripts, stylesheets, images, fonts). Here are some basic facts about its...

Creating records in specs can be so fast that two records created instantly after one another might have the same...

We upgraded a Rails 2 application to Rails 3.2 and Ruby 2.1, changed the mysql adapter from mysql to mysql2...

p ActiveRecord::Base.connection.indexes(:table_name)

tl;dr: Use with_index ActiveRecord's find_each with index If you do not provide a block to find...

api.rubyonrails.org

To avoid n+1 queries, you want to eager-load associated records if you know you need to access them...

Let's say you have two screens: Show a given project Show a report for all projects Ideally you want...

stackoverflow.com

If you want to move an element inside an array, neither JavaScript/ES6+ nor libraries like LoDash offet that natively.

makandra dev
github.com

edge_rider is Power tools for ActiveRecord relations (scopes). Please note that some of the functions edge_rider provides have...

dev.mysql.com

Directly from the MySql docs: There are three likely causes for this error message. Usually it indicates network connectivity trouble...

You know each_with_index from arrays: ['hello', 'universe'].each_with_index do |value, index| puts "#{index}: #{value}" end

Open a MySQL root shell and use this command: PURGE BINARY LOGS BEFORE DATE(NOW() - INTERVAL 3 DAY) + INTERVAL 0...

makandra dev
github.com

Provides an easy way to retrieve Google Page Rank, Alexa Rank, backlink counts, and index counts.

Code snippet tested with Rails 2.3 def index # ... if request.xhr? html = render_to_string(:partial => "list", :layout => false) respond_to...

makandra dev
linux.die.net

When connecting to multiple (i.e. > 4) servers to dive into logfiles or do security updates, terminator is what you want...

As you know, assignable_values does not invalidate a record even when an attribute value becomes unassignable. See this example...

github.com

jQuery plugin that makes it easy to dynamically add and remove records when using ActiveRecord's nested attributes.

Edge Rider gives your relations a method #origin_class that returns the class the relation is based on.

makandra dev

When you want the table headers to always stay around (e.g. because that table is huuuge), use the code below...

So you have a restangular collection and you want to remove an element from it, after you've successfully deleted...

If you are using Angular and want something like Rails' simple_format which HTML-formats a plain-text input into...

robots.thoughtbot.com

Declare an enum attribute where the values map to integers in the database, but can be queried by name.

browserstack.com

Local testing allows you to test your private and internal servers using the BrowserStack cloud, which has support for firewalls...

By default, Rails' validates_uniqueness_of does not consider "username" and "USERNAME" to be a collision. If you use MySQL...