Posts for: #Activerecord

Cached Models 0.0.2

CachedModels hit 0.0.2.

First of all, I transformed it to a Ruby gem, so you can use it outside Rails! Second, I dramatically enhanced performances, avoiding useless cache lookups and expirations. Take a look at the new benchmark stats: 1000 requests with a level of concurrency equal to 100, tooks 6 fewer seconds, if compared with standard ActiveRecord.

I strongly encourage you to upgrade to the newer version.

[]

Cached Models

cached_models provides to your models a transparent approach to use Rails internal cache mechanism.

Usually, when you decide to use cache for your ActiveRecord results, you have to manually implement complex expiring policies. cached_models simplifies your code:
class Author true end

class Post true end

That’s all!!.

A more complex example..
class Project true

has_many :tickets, :cached => true has_many :recent_tickets, :limit => 5, :order => ‘id DESC’, :cached => true end

[]

Acts As Resource: Rails 2.1 ready and moved to GitHub

Acts As Resource is ready for the imminent Rails 2.1!

I also moved it to GitHub, the new repo is http://github.com/jodosha/acts-as-resource/tree/master, the SVN one is deprecated.

If you enjoyed this post, feel free to recommend me on Working With Rails.

[]

Ruby on Rails: Test Model Domain Changes

You know how tests are fundamental for a well-developed project, for this reason we should create step-by-step a net of test cases. Of course we also should be able to change rapidly our tests as the same we do with our code. Ruby on Rails is a great framework, because its shortcuts, the wide usage of DSL etc.. All this stuff can save a lot of time, but what about tests? Are we really able to follow our code?

[]

Rails: How To Create Custom Validations

Often our model objects leaning toward to be confused or noisy, due to validations DSLs. Imagine a class Answer, with an attribute, that should be exactly a string representation of a boolean. Ok, I know it’s an odd example, but: it’s trivial enough to make this example clear, and.. It happened to me to deal with this situation. :-P

class Answer %w( true false ), :message => "Should be exactly true or false." end

[]