Day 5: Controller and View
The model layer completes the (imho) most challenging part of this project — creating a cached, object-oriented ruby model containing relevant basecamp entities. I expect the rest of this project to proceed in strides, but just burned an hour on a “gotcha.”
I’m leveraging ActiveScaffold to display the tabulated project / person / timeentry / company data. ActiveScaffold is the bee’s kees: it provides asynchronous record editing, nested forms, and you can trick it out like a 64 Impala.
Frustratingly, it just didn’t work for me — I kept getting the error message:
ArgumentError (wrong number of arguments (0 for 1)):
.//vendor/plugins/active_scaffold/lib/active_scaffold.rb:54:in `initialize'
.//vendor/plugins/active_scaffold/lib/active_scaffold.rb:54:in `new'
.//vendor/plugins/active_scaffold/lib/active_scaffold.rb:54:in `active_scaffold'
Looking at like 54 of active_scaffold.rb reveals:
# defines the attribute read methods on the model, so record.send()
#doesn't find protected/private methods instead
# NOTE define_read_methods is an *instance* method even though
#it adds methods to the *class*.
klass = self.active_scaffold_config.model
klass.new.send(:define_read_methods) if klass.read_methods.empty? && klass.generate_read_methods
So they pull the Class of my model, create an empty instance and then call “send” with the direction to “define_read_methods” on my blank object, creating accessors in every class instance. This is a little bit weird, but perfectly legal.
My error originated from my Model class. As posted yesterday, the constructor accepts a Recordwrapper instance and expects at least one input. Changing the constructor from def initialize( project_info ) to def initialize( project_info = nil ) fixed this right up, and ActiveScaffold now works like a charm.

Leave a Reply