Add Gravatars to your Rails Application I found a better way to do this! Go to the article at /2010/01/26/gravatar-default-images-a-better-way/ [https://www.thechrisoshow.com/2010/01/26/gravatar-default-images-a-better-way/] and read that instead!I wanted to add Avatars to my new project whatiwantforxmas.com [http://www.whatiwantforxmas.com] but it felt like too much
A peek at the inner workings of Hashrocket Recently the folk over at Hashrocket [http://www.hashrocket.com/] had another one of their famed 3-2-1 Launches - this time inviting as guest stars Tammer Saleh and Joe Ferris of another renowned Rails shop Thoughtbot [http://www.thoughtbot.com]. The application they worked on is called spot.us [http:
Using assert_select on strings Question: assert_select is awesome for testing dom objects – but it relies on using the standard rails response cycle. How can I use assert_select on to find dom elements in a standard string? Answer: Stub the response object! def test_big_selector_helper # the response requires a content_type
Set the default date format for your Rails application (Apologies to who I nicked this from – I can’t remember which book or blog post I found this) The default string format for Dates is the ‘Database’ format which looks like this: Date.today.to_s => "2008-09-24" So, this means if you have dates in your views they’ll
Display your KML on a Google Map (again) - now using Google App Engine KML [http://en.wikipedia.org/wiki/Keyhole_Markup_Language] stands for Keyhole Markup Language and is used to create geographically aware information. It can be tricky to write your own KML by hand- in order to display kml on a Google Map you need to save the markup into a
Five tips for testing Rails Tip One – Debugging tests I use RDebug in my apps a lot, but frequently I found myself wanting to debug my tests. Here’s how you can do it: If you haven’t done so already, install RDebug $ gem install ruby-debug Insert debugger in your code where you’d like
Is your Mephisto Blog not accepting new comments? This blog uses Mephisto [http://mephistoblog.com] – which is pretty cool and works a treat – but I realised to my horror the other day that the commenting system appeared to have stopped working. It drove me bananas! Why would it work one day, but not the next! Why would it
Five tips for contributing to Rails Note: these tips assume a basic understanding of how to contribute to Rails.If you’ve never contributed before I heartily recommend you check out Josh Sussers presentation Laying tracks [http://blog.hasmanythrough.com/2007/5/24/laying-tracks-slides] or Ryan Bates excellent railscast [http://railscasts.com/episodes/50] on the
Wee issue trying to install git using MacPorts The other day I wanted to install the hot new SCM git – and an easy way to do this is using MacPorts. So I opened up the terminal and banged out:sudo port install git-core It chugged away installing nicely until it tried to install rsync as a dependency: --->
Where's my blasted gems? If you’re anything like me, and you keep forgetting whereabouts your gems are installed, use the following command: gem environment This will pop up a handy list like this: RubyGems Environment: - VERSION: 0.9.4 (0.9.4) - INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.8
Add a picture to an excel file using YAJB and railsxls Ever find yourself wanting to generate an excel spreadsheet that includes logos or images? If you want to generate xslx spreadsheets it’s not too bad, because you can embed the image binary in the markup – but for older excel formats it can get a little trickier. Enter railsxls [https:
assert_select the order of a drop-down in Ruby on Rails To write a functional test to determine the correct order of a dropdown do the following: option = css_select("select#id_of_dropdown option")[n] assert_equal "Value To Compare", option['value'].to_s And replace id_of_dropdown with the dom id for the drop down you’re looking
Ruby on Rails: Grabbing the model object using the controller name I found myself in a situation where I was creating basically the same method in many of my controllers, the only difference being the name of the model object. For example: class ArticlesController # .... cut def set_recommended(is_recommended) @article.recommended = is_recommended @article.save respond_to do |format| format.
Default columns in fixtures Ever find yourself writing out the same old column names in fixtures just so your tests will work? Ever wonder if there’s a better way? Well there is! Fixtures, now with NEW default columns! All you need to do is bung a method in your test/test_helper.rb
Using Javascript reflection to get obfuscated Google Map object members If you’ve had much to do with Google Maps, then you’ve probably come across the GMarker [http://www.google.com/apis/maps/documentation/reference.html#GMarker] object. You use it when making your own custom markers on a Google Map. You typically use it like this: var stdIcon.
Find latitude and longitude for an address UPDATE This no longer works - go else where! -------------------------------------------------------------------------------- If you’re looking for the lat/long of an address, try my free geocoder application [https://www.thechrisoshow.com/images/display_kml/geocoder]. This app uses the Google Geocoding api [http://www.google.com/apis/maps/documentation/#Geocoding_Examples]
Quickly add Google Driving Directions to your rails application Do you want driving directions on your website but don’t want to mess around with the Google Maps api? Well, you can easily implement Google driving directions by calling the url: http://maps.google.com/maps?saddr=start_address&daddr=dest_address&hl=en So, in Rails you could
How to dynamically serve a KML file with Ruby on Rails title: "How to dynamically serve a KML file with Ruby on Rails" author: "Chris O'Sullivan" date: 2007/08/24 slug: how-to-dynamically-serve-a-kml-file-with-ruby-on-rails Serving a KML file in Ruby on Rails is way easier than doing it in asp.net. Here’s how I do it for my little display kml on
For Loop in SQL Server 2000 Here’s a just-so-crazy-it-might-work way of doing a for loop in sql server. This comes in real handy when making fake data for testing purposes. DECLARE @count INT DECLARE @command_to_loop NVARCHAR(1000) -- This example runs from 1 to 10 SET @count = 1 WHILE(@count <= 10) BEGIN --
How to dynamically serve a KML file in Asp.net 2.0 KML is the markup language that Google uses to represent markers in Google Earth – and NOW in Google Maps! How it works, is that you store the KML in a file on a web server where Google can get at it. Google then goes at caches the file, and generates
Auto zoom KML content on a google map If you’ve seen my display KML on a google map [http://display-kml.appspot.com/] page you’ll know that it doesn’t automatically zoom up on your generated markers. That’s cause I thought it was too hard and crazy to implement. Turns out I was wrong. If you’
Prevent an asp.net button from doing a postback Something that bugged me for ages in asp.net was how to prevent an asp.net button from automatically doing a postback. To prevent a postback occuring simply make the OnClientClick event return false like this:
QuickSwitch for VS 2003 Lars Engel updated my Visual Studio QuickSwitch plugin so it can now work on Visual Studio 2003. Not only that, but he made it even better – now you hit a checkbox to search through all open projects as well (not just the current project.) Find his blog post here:Quick
Search through SQL Server Stored Procedures for code Here’s a cool little script my boss showed me. If you want to find a snippet of code in a stored procedure, but you can’t remember the stored procedures name, use this query: select so.name as 'storProc' from sysobjects so join syscomments sc on so.id=sc.
Easy trick to speed up Visual Studio 2005 I found this on a Microsoft Forum Posting [http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=144370&SiteID=1] – apparently the navigation bar was slowing things down a bit – and if you’re anything like me, you never use it anyway. The navigation bar is this thing at the top: