- Teaser: Selenium for Flash! We’ve developed a Selenium-like framework for Flash. It’s pre-alpha, and needs to be extracted from it’s current home inside a project. Are you interested in a Selenium-like framework for Flash, or have you written one yourself? Let us know!
STI-weirdness. Rails surprise of the day: given a query of a
has_many :photos where Photos has STI subclasses (got that?) Rails will build a SQL query that includes the subclass types of Photo, which you might not want:
# query will have "... WHERE type IN ('Photo', 'OriginalPhoto', 'ThumbnailPhoto')"
It appears that the retardase_inhibitor might not work with Rails 2.1.X due to fixes in ActionMailer.
- JetBrains has been hard at work: they have released both a new Ruby plugin for IntelliJ, and a ruby-specific IDE (based on IntelliJ) named RubyMine.
Check out Pivot Jonathan’s wife’s art exhibit at Artist-Xchange Gallery in San Francisco, Friday 11/7 from 7-10pm:
3169 16th Street
Ask for Help
“I want to create a custom launcher for Firefox 2 and Firefox 3 with different profiles. Perhaps the real question is how do we create a custom version of a Mac application launcher, passing in the arguments we need?”
… without having to invoke it on the command line every time.
“We’re trying to delete cookies in our Controller, but they keep appearing in the headers anyway.”
Suggestion: make sure you are specifying your URL paths and domains correctly.
“Why won’t our CSS and other assets load the first time when accessing an SSL-protected domain on Engine Yard?”
It’s most likely not Engine Yard or Firefox 3′s fault. More research needed.
- It’s election day! If you are taking the time to read this geeky blog, you better have voted!
Ask for Help
“Is there some order-dependency issue with `has_many_polymorphs?”
We have a test that passes in isolation, but fails when the whole file is run.
“Any advice to setting up Lucine to allow us to search for strings with special characters, such as ‘-’, without having to wrap them in quotes?”
We have some Lucine knowledge here but feel free to give us your suggestions as well.
- We discovered why a Flash widget was reloading itself: changes the CSS
position value. We were hiding the Flash widget by moving it’s containing
div off the page with
position: absolute; left: -9000, and removing the class that had those values to show it again. It turns out that changing that
position value causes the Flash to reload. By keeping the
position:absolute setting when we both show and hide our container div, the Flash no longer reloads.
Ask for Help
“When using Rails’s date_select helper, is there a corresponding helper method to turn that date format into a Date object in the controller?”
Some Snippets are available, but how about a Rails built-in solution?
- Where am I? — Ever need to find the name of the method you are currently within? Here’s a
this_method method! The magic is in the REGEX, of course.
caller =~ /`([^']*)'/ and $1
- One project wanted to test a very ActiveRecord-specific Module in an isolated, generic way. After spending time researching techniques of mocking and stubbing the many, many ActiveRecord methods that would be touched, they decided to just dynamically create an ActiveRecord and a DB Table for it on the fly! They even used single table inheritance (STI)
describe "MyMagicModule Mixin" do
:force => true do |t|
t.integer "some_model_b_id", :limit => 11
class SomeBaseModel < ActiveRecord::Base;end
class SomeModelA < SomeBaseModel
class SomeModelB < SomeBaseModel
it 'should use special belongs_to stuff from MyMagicModule' do
model_a = SomeModelA.create!(
:name=> "Model A",
:some_model_be => SomeModelB.create!(:name => "Model B"))
# test the functionality from MyMagicModule
Ask For Help
Once again, a project is asking for everyone’s favorite IE 6 .PNG alpha transparency fixes — more rounded corners! Examples include the CSS Behavior code, using .PNGs or .GIFs with on/off transparency, regulating IE 6 to the square Web 1.0 world, and even using on/off transparency and just knocking a pixel or two off of corners for a “good enough” rounded look.
What are your favorite IE 6 rounded-corner and/or alpha-transparency fixes?
One client decided that Web 2.0-style rounded corners are only needed in Firefox and Webkit-based browsers because they are “free” with CSS properties built in for those rendering engines:
-webkit-border-radius. Internet Explorer is going to be left in the 1.0 world, at least for now, due to the over head of managing rounded corners.
Feel free to promote your personal favorite rounded corner techniques in the comments.
Ask for Help
“We need to hide a flash widget without setting it to
display:none, which causes it to be loaded from the server again when
display:none is removed.”
Hit me with your div-hiding techniques!
- Move it off the screen with
- Shrink it down to nothing with
visibility:hidden;height:0;width:0 but watch out for any IE 6 minimum height/width issues
- Similar to the above, hide it with
- As suggested in 09/03, one project switched to using Solr for search indexing. We were warned that wide range queries might be slow (looking for a value between 1… 10000) could be very slow, but it is not, at least with 400K indexed documents. We’ll watch out for slowdowns as the number of indexes increases.
Ask for Help
“JSUnit tests do not show line numbers for assertion failures, which makes it hard to know which assertion failed. Suggestions?”
Have fewer assertions per test, or use the message argument, such as
assertEquals(foo, bar, 'foo should be the same as bar.').
“Is there any way to see test failure stack traces as soon as a test fails or errors? This would be especially nice for slow-running Selenium tests.”
A few Pivots remember hacking on
Test::Unit and Rspec to display failure details immediately, but more research is needed. Perhaps there’s a plugin?
“Design Adam’s beard!”
Pivot Adam is shaving is beard and is looking for facial hair suggestions. Over the years he has displayed many of the “standard” beards and mustaches, so it’s time to get creative. Look to The Quest For Every Beard Type for inspiration. Here is your canvas:
Ask for Help
“Is there something wrong with Net::SSH in the latest versions of Capistrano? I can’t deploy to localhost…”
Not that anyone knows of. Have you tried turning it off and on again? The power button… it’s the little glowing button on the front… the button on the front… Are you from the PAST?
“Is there a good ruby Gem or Plugin for working with the Google Charts API?”
One pair used gchartrb but abandoned it almost immediately. So far, it’s string << string << string.
Unfortunately not. Desert plugins should have an
Watch out for Firebug 1.1.0b12 for Firefox 2! It is The Evil. Several hours have been wasted as teams try to figure out what they are doing wrong (“Why are all of the fonts twice as big?!?!”) only to find out that this version of Firebug was the culprit.
- Uninstall Firebug from the Tools – Add-ons menu
- Restart Firefox. Do not skip this step!
- Install Firebug 1.0.5
Standup fun-stuff edition!
- Where are all of the Pivots? Hmmm…
Ask for Help
find(:first, :order => 'id DESC') returns the records in the wrong order!”
Rails 2.0.2. Roughly 1 out of every 15 times, the first
id is not the first one returned. Very very strange.
Update 07/11/2008: A fix has been committed for the
- In Rails 2.0.2, we have seen a strange behavior when you have a
belongs_to association declared on an ActiveRecord class, but the table does not have a foreign key for that relationship. Within a session, everything appears normal. The child object will still be saved, the parent object can even be reloaded. But by the next session, the child object is in the database, but cannot be retrieved.
- When using
named_scope, adding a
:joins option will “mix-in” all of the attributes from that join table into your retrieved object, potentially overwriting any colliding attributes (including
id … ouch!). There was consensus that this was a valuable feature, when used “properly”. Adding
:select option can avoid this, or use
- We ran into an issue when using the JS Routes plugin in combination with Rails’ asset packaging. When asset packaging is invoked using
named_routes.js file usually has not been generated, and application crashes at startup. Solution: we created a rake task to generate the
named_routes.js file and run that as part of our deploy process.
Ask for Help
“Why did my JS
respond_to block suddenly start rendering the HTML template instead of the RJS template?”
Rails 2.0.2; controller, action,
respond_to block all work as expected. Just wrong file gets rendered. They fixed the problem by adding an explicit call to
render but this should not be necessary. Suggestion is to move from the template.rhtml naming scheme to template.mime-type.render-engine scheme and see if it is fixed.