Kelly Felkins's blog
Ask for Help
"Do you have to use to_param in functional tests?"
In the past you could simply provide an object in a param list in functional tests and the to_param for the object would be called to get the proper value for the parameter. This is now broken, forcing you to use object.to_param every time.
Perhaps not helpful for existing projects but I recommend you use cucumber, webrat, or even selenium rather than Rails functional tests. Rails functional tests require that you specify parameters and specify them correctly. If you get them wrong your functional tests might continue to pass for the wrong reason. Here's another "bad params in functional tests" post.
Interesting Things
- Rubyconf program should be available today on their website
Interesting Things
One team reported that Capistrano can't deal with host aliases in .ssh/config. Others use host aliases with capistrano without trouble. The problem could be related to multiple host aliases. All this led to the statement:
If you are working with EY, you should go all alias, all the time.
Problems with JsUnit and Firefox 3.5. From Adam:
If you're planning to use JsUnit, or you already use JsUnit and you plan to upgrade your Firefox to version 3.5, you may run into this problem. Apparently the security settings in Firefox were updated in 3.5 to restrict file access in a way that stymies JsUnit. If you don't fix this JsUnit will fail to open test files, and will simply hang on tests runs, with no error output. To fix it:
- type 'about:config' in the Firefox URL bar
- Filter by 'security.fileuri.strict_origin_policy'
- Set this to false
Ask for Help
"Has anyone used Unicorn"
No one present is using Unicorn. Some wondered how it differs from Thin.
This raised the question:
"Is there a road map for mongrel and rails? Mongrel uses CGI and Rails 2.3 has removed CGI."
In the Ruby on Rails 2.3 Release Notes, there is the statement
...but if you use CGI, don’t worry; Rails now supports CGI through a proxy interface...
Interesting Things
- IE doesn't allow you to change the type of an input. If you create an input with createElement, IE will not allow you to change that element to a button. This was discovered when a project's javascript dom builder code was modified to generate inputs of type=button rather than type=submit. The cross-browser solution was to create some other temporary dom element such as a div and then set the innerHtml of that element to a type=button input, then extract that child element and return it in the builder call. Yeah!
Ask for Help
"What's the best way to get gems for forked repos?"
There was quite a discussion on this. The specific issue is that the team is trying to use Compass (Chris Eppstein gave a talk on Compass at Pivotal on 3/18-look for the future video on our Talks Page.) For the moment, since compass depends on the edge version of sass you must first manually install sass before installing the compass gem.
- One suggestion was to submit a fix for the gem. This is not a good solution in this case since the new version of sass/haml is expected to be released soon, fixing compass and simplifying its installation.
- Pivotal will likely host its own internal gem server at some point to deal with issues like this.
- The Has My Gem Built Yet? service might be useful in some situations, but not for this specific problem.
Ask for Help
"How do you test request headers? The request object is frozen..."
The team is using rspec to test an OAuth implementation and needs better access to the request object.
- Possibly modify the request environment prior to running the test -or-
- Instantiate a new, non-frozen request object.
Interesting Things
- Branches + JsUnit + CI + IE = :-( : Apparently it is difficult to manage IE's cache in CI. One project apparently has a bat file on CI that clears the cache every 30 minutes. Another team solved this by making the cache directory read only. Often browser/OS combinations have some technique for disabling caching.
- Test Swarm Alpha: this is a crowd sourced javascript testing solution (think seti@home for javascript testing) being developed by John Resig.
Ask for Help
"AR attribute appears to be skipped by text field helper?!" Apparently the model method is bypassed by the text field helper if a column of the same name is present in the underlying table. This was experienced in Rails 2.2.
Others have apparently experienced this in the past but a clear answer did not surface.
Interesting Things
- Browser History with Javascript and Page Based Json: One of our projects solved the vexing problem of browser history for a page that has initial page provided json with subsequent ajax updates. A simple page back operation will display the originally downloaded data, not the updated data. The solution is to add a unique id for each page, and store these ids in a cookie. When an ajax request updates the page it removes its page id from the cookie. When you use the back button, each page checks to see if its unique id is in the cookie, and if it is not, it forces a reload.
Really Simple History was mentioned as another way to manage javascript/ajax history. - Rubymine Build 784 has the Weirdest. Bug. Ever.: This may only be a problem if you work on a mac and you need to enter capital letters in rubymine dialogs like find and replace ;-). Many of us are fans of intellij/rubymine, but we wish they had a better test process. To be fair, rubymine is in public preview, so expect the occasional bug or two.
Interesting
- firebug lite 1.2 is out
Ask for Help
We upgraded to rails 2.1 and polonium and our rspecs are not running on CI, but run fine if you simply use rake on the command line.
Check to see if you are using the rake extensions in pivotal core bundle.
Using setTimeout() to wait for DOM to update in JsUnit does not work.
Using setTimeout in tests is not going to do what you want, unless you mock setTimeout. Basically, setTimeout kicks off another thread which is not likely to effect the current test.
Interesting

- There was war story told involving software that's not generally available. However, one tidbit that may be of general interest is a reminder that you don't necessarily get a perfect copy of your mysql database when restoring from a dump of that database. Mysqldump by default writes the data of each table preceded by a
DROP TABLE IF EXISTSand aCREATE TABLEstatement. This covers you in most situations, but misses when new tables have been created since the dump was made -- those new tables are not deleted. They may not cause problems, but some systems are sensitive to the existence of those tables, such as rails and theschema_infoandschema_migrationstables.
Ask for Help
- question: Is merb hosting different from rails hosting?
- answer: no
Interesting
- attr_readonly marks an attribute as, ah, read only -- use it to tell ActiveRecord that an attribute should not be a part of update operations. Rails uses attr_readonly internally with counter caches (search for "counter_cache" under ActiveRecord::Associations::ClassMethods) since counter caches are incremented/decremented directly in the database with sql. Without attr_readonly, subsequent updates of the counter_cache'd model would revert the counter to the value of the counter at the time the model was loaded.
Note: attr_readonly was either buggy or not exposed prior to 1.2.3. If you are using a version of rails prior to 1.2.3 you can do this instead:
def attributes_with_quotes(include_primary_key = true)
attributes.inject({}) do |quoted, (name, value)|
if column = column_for_attribute(name)
# original:
# quoted[name] = quote_value(value, column) unless !include_primary_key && column.primary
quoted[name] = quote_value(value, column) unless !include_primary_key &&
(column.primary || ["your_attributes", "listed_here"].include?(column.name))
end
quoted
end
end
Ask for Help
- help: Looking for recommendations on converting an existing schema to a new schema. We are considering dumping the existing schema to yaml (using ar_fixtures) and making the transformations there.
- answer #1: One recent project had a "liberate" script that extracted information from the legacy database via sql statements and constructed AR model objects as necessary. The liberate script grew to some 1500 lines of code and was refactored many times.
- answer #2: Another project did the data migration by first importing the legacy database and then using rails migrations as needed to transform the data to the new schema. Most of the migrations used sql for the transformations. These migrations did not have associated unit tests.
- Please offer your suggestions in the comments.







