Remember when we used PHP? Multiline commenting was simple…a little /* here and some */ there and viola! That’s one of those little things that has irked me with Rails, the inability to comment out multiple lines.
January, 2008
18
Jan 08
Multiline commenting for your Ruby on Rails apps?
17
Jan 08
Ruby on Rails Join Tables
It’s the simple things that seem to cause the most problems. Recently I had a problem with my Has and Belongs to Many relationships in one of my applications.I wanted to add an Offer to an Offer Group without using SQL to directly write to the join table (as my boss put it…just codetend it doesn’t exist).
I had a list box in my view which would pass my listbox parameters forward. Then, depending on the selection I would either add or remove something from the join table.I kept encountering an error where a record would exist.
After I dropped the ID column from the join table, all was well. Yeah…ID column…seriously!
Here’s the migration I used to create the join table:
def self.up
create_table :offer_groups_offers do |t|
t.integer :offer_id
t.integer :offer_group_id
end
end
def self.down
remove_table :offer_groups_offers
end
end
17
Jan 08
Random Images in your Rails App
Ever want to get a random image from a folder in your rails app? Well, here you have it…place this in your application helper:
module ApplicationHelper
def random_header_image
image_files = %w( .jpg .gif .png )
files = Dir.entries(
"#{RAILS_ROOT}/public/images/random_image_folder"
).delete_if { |x| !image_files.index(x[-4,4]) }
files[rand(files.length)]
end
end
16
Jan 08
Kerscher sideskirts on the B6 S4
Some photos from the installation of the Kerscher sideskirts. Notice the OEM B6 S4 doorblades don’t flow very well with them?


15
Jan 08
Foreign Key Migrations in Rails 2.0
Before Rails 2.0, adding a foreign key column to your migration was easy:
def self.up
create_table :offer_group_listings do |t|
t.integer :offer_id
t.integer :offer_group_id
t.integer :weight, :default => 0
t.timestamps
end
end
def self.down
drop_table :offer_group_listings
end
end
With 2.0, it’s even EASIER!
def self.up
create_table :offer_group_listings do |t|
t.references :offer, :offer_group
t.integer :weight, :default => 0
t.timestamps
end
end
def self.down
drop_table :offer_group_listings
end
end
13
Jan 08
The Seahawks Coug’d It
14 points in the first 5 minutes, and we can’t win a damn game? Reminds me of Applecup ’07 :/
11
Jan 08
Tips to Improve Your Video?s Ranking on YouTube
I got this information from our Google Agency Services weekly update newsletter. It has some helpful tips if you use YouTube.com for viral traffic. Be sure to also watermark your videos and/or have a URL slide at the end so users can type-in your website address if they want to visit your site.
Tips to Improve Your Video’s Ranking on YouTube
YouTube video search uses a variety of signals to determine the placement of a video in our rankings, including the video file name, title, and any associated metadata. The more information provided about a video, the better it can be searched. In general, we strive to give the best possible objective video result. However, there are some best practices that clients can use that will help their rankings:
* Add a Descriptive Title to Your Video – When users search for a video on YouTube, they will find your content easier if you include an accurate and descriptive title for your video. An engaging title can also help your video stand apart from the rest of the crowd.
* Make Your Descriptive Content Clear and Specific – Try to determine what content your video contains that will help users find it and distinguish it from other videos. Providing content that is descriptive, accurate, and unique is an important factor. Using complete sentences in your description is also a good idea. For more information, you can reference What should I put in my video description?
* Provide Accurate Tags – Including tags that users may use when they search or browse videos also helps. However, avoid using techniques such as keyword stuffing which will ultimately hurt your videos rankings.
* Community Opinion – Our vast and highly engaging YouTube community is an important factor that can affect the ranking result of your videos. Signals from users who share, comment, rate, watch, subscribe to and embed your videos are also taken into consideration when ranking videos.
* YouTube Embeds and Links – YouTube also takes into account links from reputable websites that point to your video. Web sites that are “important” and point to your video may improve your videos ranking. Similarly, YouTube also takes into the consideration reputable websites that embed your video. For information on how to embed videos, please refer to How do I embed videos on my website or blog? Google has also published webmasters guidelines that apply to all sites that embed or point to video content. This document also provides important quality guidelines that webmasters should take into consideration when linking to or pointing at videos.
Using these and other factors, YouTube strives to provide the most accurate and relative video search results. YouTube also continues to modify and improve its algorithms to ensure accurate results and create a better user experience.
11
Jan 08
Testing with Basic HTTP Authentication in Rails 2.0
I ran into a little issue while writing functional tests in Rails 2.0, using the included HTTP authentication I’d find my controllers returning 401 errors since they weren’t authenticated. After poking around, I found a solution:
def http_auth
@request.env[”HTTP_AUTHORIZATION”] = “Basic #{Base64.encode64(”foo:bar”)}”
end
end
Then, in my actual tests I could call:
10
Jan 08
Yet another snow storm hits the Cascades
I’m planning on heading over to Walla Wall this weekend and it’s apparent I’ve got poor planning.
Looks like there’s going to be up to 20 inches of snow…let’s see how the winter tires and Quattro holds up!
9
Jan 08
JL Audio’s 10w7
Well…I get an email from the shop telling me I have a few packages. Curious, I drop by…and what do I see? My JL Audio 10w7! My first reaction was, wow, the box has two handles on it…eek!
After unwrapping my new toy, I was very impressed with the overall construction of the speaker. Everything from the surround, to the wiring terminals looked to be of high quality. I hope to run the amp wires this week and drop this sucker in!