Notes posted by jrochkind
RSS feed
0 thanks
How to set request parameters (rails 3.2)
In Rails 3.2, this seems to work to create a TestRequest based on a certain url:
ActionController::TestRequest.new( Rack::MockRequest.env_for("http://something.tld/foo?one=two&three=four") )

0 thanks
1.9 behavior
“In Ruby 1.9 and newer mb_chars returns self’”
This would seem to be a lie. At least in rails 3.1.0 and ruby 1.9.2, mb_chars still returns a proxy object with additional useful methods defined on it that aren’t on a 1.9.2 String.
ruby-1.9.2-p180 :007 > "àáâãäå".normalize(:kd) NoMethodError: undefined method `normalize' for "àáâãäå":String ruby-1.9.2-p180 :008 > "àáâãäå".mb_chars.normalize(:kd) => àáâãäå

2 thanks
beware of trying to dup in subclass inside class context
The example of adding to an array without effecting superclass:
# Use setters to not propagate changes: Base.setting = [] Subclass.setting += [:foo]
That’s right as far as it goes. But beware when you are in context of class definition:
class Subclass < Base # possibly wrong, ruby seems to get # confused and think you mean a local # var, not the class ivar setting += [:foo] # But this will work: self.setting += [:foo] # Or: self.setting = self.setting.dup self.setting << :foo [...] end