Joe Moore's blog
Standup 03/30/2007
Interesting Things
- Rspec vs. Rails' Test::Unit Gotcha: In a Controller test, Rspec provides access to that Controller's attributes with
assigns[:attr_name], or "array notation", but Test::Unit does not. Both supportassigns(:attr_name), or "method-call notation."
Ask for Help
- "How should we migrate/upgrade database when we add new versions of assets, such as photos?" The consensus is that, for now, we'll do it lazily: if an application (using our asset management plugin) needs a new version to be stored (perhaps we need a 'tiny' version...) when we will create them on-the-fly when requested rather than generate thousands of photos in one shot. If that has performance implications we'll revisit that decision.
- Anyone want to be RailsConf roomies? Our sizable RailsConf contingent is going to try to share hotel rooms and such.
- We're out of beer! A posse of those whom have been late to standup will make a run later today
Total Stand-up Meeting Time: 13:00 minutes
Standup 03/29/2007
Interesting Things
- Rails Gotcha: If you name a Rails Migration class the same name as an ActiveRecord class, you will get a non-obvious "superclass mismatch" error.
- Javascript:
Date.now()is not supported by Internet Explorer! Firefox is fine. If you useDate.now(), the cryptic and maddening "Object does not support this property or method" will be your reward. Cross-browser solution:new Date().getTime(). - Brown Bag Lunch today: Rails performance testing.
Ask for Help
- "Any JQuery experts in the house?" Unfortunately not, since most of us have used the Rails-favored Prototype libraries.
- If anyone has unbiased hosting service recommendations we would love to hear them. We've used several companies with mixed results.
- Rspec: "Does Rspec support all of the various route testing helpers that Rails' Test::Unit extensions has?". We think the answer is "yes" because Rspec extends Test::Unit, but we'll have to research that one.
Total Stand-up Meeting Time: 15:00 minutes
Standup 03/28/2007
Interesting Things
- One pair had this reinforced: you should not generate random data in your test case to be the subject of your assertions. In their case they were generating random usernames to test an "allowed characters" filter, but their tests would intermittently succeed or fail because the test was not deterministic.
- "A
privatedeclaration in a Helper doesn't do jack crap!" Truer words were never spoken:privateandprotecteddeclarations are not enforced in Rails View Helpers due to how that code is injected into View instances. - A developer suggested that we attempt to do "RESTful CSS." An explanation and debate is due soon.
- We are officially changing Wiki technologies from Twiki to Trac.
- Rails Gotcha: You can use Named routes to generate a URL for a link with
my_named_route_url, but watch out: that URL is fully qualified! If you want a relative "URL", usemy_named_route_path. Example:
<code> # config/routes.rb login "/login", :controller => "user_management", :action => "login" </code>
And in a any RHTML template:
<code> login_url # generates http://example.com/login login_path # generates /login </code>
- People need to take more time to... blog! We have a laundry list of topics but no free time.
Total Stand-up Meeting Time: 17:00 minutes
Standup 03/27/2007
Interesting Things
- Rails Observers: Observers need to be "primed" before they start working. Call
Observer.instancebefore you start testing your Observers. - Cookies in Rspec and Test::Unit: Cookie keys are not symbols, unlike many collection-like constructs in Rails; they are instead always Strings. Thus, use
"cookie_name"not:cookie_name - Rails reminder: ActiveRecord::create returns the stored object if successful, and the unsaved and invalid object in memory if the object could not be saved. If you want to know whether or not your save was successful, use ActiveRecord::save, which returns
truewhen successful andfalseotherwise. - And on a further note, a larger discussion should be had regarding when to use ActiveRecord::create, ActiveRecord::save, ActiveRecord::new, and ActiveRecord.dependent_object.build the latter of which is created when you have a
has_manyrelationship with anotherActiveRecord.
Total Stand-up Meeting Time: 20:00 minutes
Standup 03/26/2007
Interesting Things
- Running initialization blocks per environment
- Set an array in
environment.rbto capture your procs that will do your post-initialization:POST_LOAD_BLOCKS = [] - Now, in your environment-specific initialization files, you can do stuff like:
- Then, back in
environment.rb, after your environment has been initialized, loop over your array:
- Set an array in
<code>
POST_LOAD_BLOCKS << Proc.new {
a.runFoo
b.runBar
}
</code>
Paydirt! These procs you're appending to the POST_LOAD_BLOCKS array will get executed after your environment is completely initialized.
- Use
silence_warningsto (you guessed it!) 'silence' warnings in Ruby - only pros should use it, and only when its clear exactly what you are doing!
Ask for Help
- None need today
Total Stand-up Meeting Time: ?
Standup 03/21/2007
Interesting Things
- We've forked several 3rd party plugins (yes, we need to send patches) and we're using the "3rd Party Branch Pattern" from Software Configuration Management Patterns. We'll keep you posted as to how it's working.
rake db:fixtures:loaddoes not turn off database foreign key constraints, so be careful. We'll see if we can either fix this for our needs or make it configurable.- CSS: We've found a technique claiming that
overflow:hiddencan dispose of the un-hip<div style="clear:both;"></div>float-clearing div. This seems to have multiple side effects, including undesirable scroll bar behavior, so be very careful if you do this. - In FireFox for Mac, you will encounter problems if you are trying to hide a Flash components using an opaque
div. There is a workaround involving a.pngbackground image which has the desired alpha-transparency... a more detailed post will (hopefully) come in a follow-up post. - Even More CSS: though some suggest it's dangerous, setting an element to
position:relativeoften saves the day if you have having layout problems.
Ask for Help
- One of our new projects is using the Darcs source code management system... has anyone used it?
- We have a few who've read about it, but not used it... looks like we'll have to RTFM.
- If anyone has experience getting rake tasks to work on both *NIX and Windows, talk to AC.
- Here's a good sign: we're out of chairs!
Total Stand-up Meeting Time: 24:00 minutes
Standup 03/20/2007
Interesting Things
- An internal project has migrated to Ruby 1.86 and Mongrel 1.0.1 with no ill affects, with the bonus that this combo fixes a known memory leak in Mongrel.
- Ruby Fu: it was pointed out that Ruby method argument defaults can refer to other arguments to that same method:
<code> def wrangle_monkey(x, y = x + 1) # Above, `x + 1` refers to to method argument `x` end </code>
- One project wrote a super-cool rake task that helps manage JSUnit servers and test runs. Talk to A.C. if you are interested.
- Rails Helpers and template's use of erb is...weird. Details are blurry and the developers who discovered the issues should post the heavy stuff on this blog, but suffice to say don't be surprised if you have trouble working with the erb output stream in your helpers.
Ask for Help
- The Men's room key is missing, and one team needs CSS help... hopefully these are not related.
Total Stand-up Meeting Time: 16:00 minutes
Standup 03/19/2007
Interesting Things
- Markaby: while Rails helpers are available when using Markaby to generate HTML, some of those Rails helpers do not return strings of HTML, but instead add content directly to the ERB output stream, which won't help you. You can capture this ERB output by using the Rails helper
capture(). - The appable_plugins folks fixed the Class non-reloading issue we talked about earlier. Thanks guys for fixing Bug 7!
- Adobe just released their Apollo framework, which allows web applications access to a computer's local file system, amongst may other features.
Ask for Help
- Please save us from... PS2 keyboards! We're flooded with them. Perhaps we can use them in an art project.
Total Stand-up Meeting Time: 14:00 minutes
Other articles:







