Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A workaround to ensure multiparameter assignment still works when you delegate date/time Active Record attributes
branch: master

This branch is even with saks:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
tasks
.gitignore
MIT-LICENSE
README.textile
Rakefile
VERSION
delegate_temporal.gemspec
init.rb

README.textile

Delegate Temporal

This Rails plugin allows you to continue to use multiparameter attributes when the actual
attribute is delegated to another object.

The problem

class Foo < ActiveRecord::Base
  ...
  delegate :start_time, :start_time=, :to => :appointment
end

@foo.attributes = { "start_time(1i)" => "2008", "start_time(2i)" => "9", ... }
# => Error!

The error occurs because Rails tries to look up the “start_time” column in the database (in order to
find out information about its type), but because we are delegating it doesn’t exist.

The solution

Install this plugin, and then:

class Foo < ActiveRecord::Base
  ...
  delegate_temporal :start_time, :to => :appointment
end

@foo.attributes = { "start_time(1i)" => "2008", "start_time(2i)" => "9", ... }
# => Yay, it works!
Something went wrong with that request. Please try again.