Update timestamp of a model in Rails

Recently I need to update timestamps of a model because I use this value as "last seen". In a Job, I update a model or others associated to it, so in the second case, I need to update timestamps. Instead of use model.update(update_... Read.more

Ruby safe operator

Edited on Jan. 14 Finally, the safe operator was updated from .? to &.. See this comment from Matz. Ruby Safe operator Recently, I read in reddit about a new feature in next Ruby minor release: Ruby Safe operator. &. is used to call a method... Read.more

Multiple assignment in Ruby

On Ruby we can assign multiple values to our variables. These assignments are very useful to reset variables and return multiple values from methods. Multiple assignment There are two ways to assign multiples values to variables: # First a, b = 1, 2 puts "#{a}, #{b}" # 1,... Read.more

Material icons for Rails

Using a font icon set is a nice option for the interface of your websites and applications. These sets include a lot of icons in one file, so they usually will cover all needs of your projects. In addition, they have more advantages: Supported by... Read.more

Determine if model is just created

Sometimes we need to know if a model is just created after save if for first time. Rails doesn't provide a method to check this situation, so we need to use a small trick. If we have timestamps (specifically created_at and update_at) columns... Read.more