Archive for March, 2009
dm-is-remixable and overwritten property accessors
March 31st, 2009 •
tags: datamapper, ruby
I just stumbled across some weirdness in dm-is-remixable. Seems like overwritten property writers work, whereas overwritten property readers don’t … hmm …
merb-helpers should produce valid html id attributes
March 25th, 2009 •
tags: merb
A Ticket for this issue can be found here …
# stick this in init.rb's before_app_loads block
# until this issue maybe gets resolved in merb-helpers
module Merb::Helpers::Form::Builder
class Form < Base
def update_unbound_controls(attrs, type)
if attrs[:name] && !attrs[:id]
# this makes sure that the '[]' characters which are not valid
# in html ids, don't get copied over. furthermore, the trailing '_'
# character makes sure that this id stays unique (particularly
# necessary for additionally generated hidden inputs as they
# are generated for checkboxes for example). the 'to_s' call
# is necessary in order for the merb testsuite to run. obviously
# there are some tests that use the Symbol :truez as a name
# attribute, and since Symbol#gsub is private, tests fail if the
# name attr isn't always converted to a String before use.
attrs.merge!(:id => attrs[:name].to_s.gsub(/(\[|\])/, '_'))
end
case type
when "text", "radio", "password", "hidden", "checkbox", "file"
add_css_class(attrs, type)
end
super
end
end
end