devblog of @sgt_mactavish
Problem using ActiveRecord #exists? in eager load resultset
So few weeks ago i’ve got problem in a rails apps. New Relic reports about 500 error, where the main cause is accessing method in nil object. Here is code snippet, causing the error : ```ruby class User < ActiveRecord::Base has_many :posts, -> { order “created_at DESC” }
Progressbar Upload with Refile Gem
There is a ruby gem library for file upload called refile. One of features that i like is built in javascript library, which is contains several custom DOM events. These events also can be listen, so you can provide logic easily around file upload lifecycle process.
Install Rmagick On OSX Yosemite
So i’ve problem when installing rmagick gem in macosx yosemite, although i’ve installed imagemagick on my system. The problem exists when bundler try to install rmagick gem and having trouble finding MagickWand.h for building native extension. bash Can't install RMagick 2.13.2. Can't find MagickWand.h. *** extconf.rb failed *** Could not...
ruby inject method
Ruby inject method is useful for combining an element inside enumerable, with binary operation and initial value.
CarrierWave uploader for tableless model in Ruby on Rails
In this post i want to share my experience in implementing Carrierwave for tableless model, for example i’ve model User : ruby class User attr_accessor :id, :name, :avatar ... end I need to store user’s avatar using carrierwave, in this case i create AvatarUploader, the problem is how i store...