21 May 2012

The Ruby Reflector

 
Star Following

  Source Favicon
By Casper Fabricius of casperfabricius.com 8 months ago.
Email

API client and something we call ActivePodio , which is an attempt to get interacting with a RESTful API to feel a bit like using ActiveRecord.

The talk is in Poznan, Poland on October 14th. If you can't make it there, but are near Copenhagen, you can also see our rehearsal of the talk at the Copenhagen Ruby Brigade meeting on October 10th.

casperfabricius.com Read
  Source Favicon
By spastorino of Riding Rails - home 8 months ago.
Email

ActiveRecord

Add deprecation for the preload_associations method. Fixes # 3022.

[ Jon Leighton]

Don't require a DB connection when loading a model that uses set primary key. GH # 2807.

[ Jon Leighton]

Fix using select() with a habtm association, e.g. Person.friends.select(:name). GH # 3030 and

2923.

[ Hendy Tanata]

Fix belongs_to polymorphic with custom primary key on target. GH # 3104.

[ Jon Leighton]

CollectionProxy#replace should change the DB records …

weblog.rubyonrails.org Read
  Source Favicon
By David Eisinger, Senior Developer of Viget Extend : The Development Lab 8 months ago.
Email

…faster than doing the regular expression matching in Ruby, mostly because of the lack of ActiveRecord overhead.

Caveats

Using regular expressions in your SQL has the potential to be slow. These queries can't use indexes, so a full table scan is required. If you can get away with using LIKE , which has some regex-like functionality, you should. As always: benchmark, benchmark, benchmark.

Additionally, MySQL supports POSIX regular expressions, not PCRE like …

viget.com Read
  Source Favicon
By Gregory Brown of Practicing Ruby 8 months ago.
Email

…bit of a weird LSP issue, let's think about what happens when you subclass an ActiveRecord::Base object. Technically speaking, if we give ourselves a pass for breaking signature of methods provided by Object, we'd still need to keep track of all the behaviors ActiveRecord::Base provides, and take care not to violate them. Here's a brief list of method names, but keep in mind we'd also need to match signatures and return values. >> ActiveRecord::Base.instance_methods(false).sort …

blog.rubybestpractices.com Read
  Source Favicon
By spastorino of Riding Rails - home 8 months ago.
Email

ActiveRecord

LRU cache in mysql and sqlite are now per-process caches.

lib/active record/connection adapters/mysql_adapter.rb: LRU cache keys are per process id.

lib/active record/connection adapters/sqlite_adapter.rb: ditto

Database adapters use a statement pool for limiting the number of open prepared statments on the database. The limit defaults to 1000, but can be adjusted in your database config by changing 'statement_limit'.

Fix clash between using 'preload', …

weblog.rubyonrails.org Read
  Source Favicon
Email

…3.1 final release. Like Dr Nic, my favorite feature of Rails 3.1 is ActiveRecord's prepared statement support. SQLite3, PostgreSQL and SQL Server now use prepared statements to yield " 2x faster for simple queries and 10x faster for complex ones !"

Exciting feature number three is for you if you are using SQL Server on Windows: the latest ActiveRecord SQL Server Adapter, TinyTDS and FreeTDS are now included! TinyTDS is a project from …

engineyard.com Read
  Source Favicon
By Michael Blake of Running With Rails 9 months ago.
Email

…set of standard tools for his career path. If he is a self-described ruby developer you will find ActiveRecord and Rails in his toolbox, Ruby and little else. A self-described web developer will have a wider but similarly focused toolbox, containing perhaps PHP, Rails and Javascript with a touch of CSS.

These boxes that they place themselves in will limit their ability to innovate severely. With exposure to only a small world of web development tools a webdeveloper codemonkey will …

runningwithrails.com Read
  Source Favicon
By trevorturk of Engine Yard Ruby on Rails Blog 9 months ago.
Email

MongoDB's GridFS store. There's ORM support available for ActiveRecord, Mongoid, DataMapper, Sequel, Mongo Mapper, CouchDB, and more. Image processors are available for RMagick, ImageScience, MiniMagick.

Let's see this modularity first hand by building up a CarrierWave uploader from scratch.

To begin with, we'll install CarrierWave: gem install carrierwave

Then, we can make the world's shortest uploader: require 'carrierwave'

engineyard.com Read
  Source Favicon
By Gregory Brown of Practicing Ruby 9 months ago.
Email

This mock emulates a simple ActiveRecord search, returning a stubbed out record which implements the bare minimum functionality required by our GeoRegion class. While somewhat uninteresting, below is the definition of record_stub() , for those curious. def record_stub stub(:the_geom => Object.new) end

The guts of GeoRegion are actually a little bit complex, but our test was only meant to show that GeoRegion.by postal returns an object that responds to interpreted_type() and …

blog.rubybestpractices.com Read
  Source Favicon
By Andre Foeken of Journal 10 months ago.
Email

They mimic an ActiveRecord object but instead of the database values, they return stuff like "${id}". This is what jQuery uses to replace values. This works like a charm. There are some snags: everything the rails partial echo's into the html must be a method on both the real and fake ActiveRecord model. This is especially interesting if you are using localization.

I use these templates together with the content of the message I get from faye. Putting them together renders …

movesonrails.com Read