Posts tagged: howto

Rails: Rendering Dynamic SVG Images in respond_to

SVG is a vector image described in XML. This post shows how to to render SVG images inline with Rails.

Android: Consuming a Remote JSON API with Volley

In the previous tutorial, you learned how to use Volley’s built-in networking tools to quickly download a network resource and display the results. Volley removes lots of boiler-plate code, and lets you concentrate on the details of your app rather than dealing with low-level networking technologies.

Android: Getting Started with Volley

Volley is a library developed by Google for fast, easy networking in Android. It wraps up a lot of boiler plate code that you would normally have to code yourself when connecting to servers, queuing requests, handling errors, caching, etc.

Android: Using Gradle

On a couple of Android projects I’m working on, I’ve switched to using the new Gradle Build system. The idea of storing the entire build configuration in one place is great.

Android: Getting Started with Databases and ContentProviders Part 1

Clone the code from GitHub

Testing Rendered Views with RSpec2, Capybara and Rails 3.

While view tests are brittle, easily breaking when the design of a page changes, they are undoubtedly handy for checking the important parts of a page are rendered. I usually check for page titles, model attributes/tables or forms, and footer element, and so on.

Android: How to test Local Web Apps on an Emulated Device (AVD)

Android AVD running local Web App

Rails 3: How to Autoload and Autorequire your Custom Library Code

Every time I start a new Rails 3 project, I’m always caught out by its autoloading behaviour. Rails 3 will only require (and so autoload) a module when it is first encountered within the application code, for example by a call to include or require.

Ubuntu 11.04 Beta - How to test Unity in VirtualBox 4

Ubuntu 11.04 Beta ScreenshotIf you like to test out the latest and greatest builds of Ubuntu, you might like to try the latest 11.04 beta in VirtualBox.

Android: Spinner-Like UI for Selecting Multiple Options

Rails 3: How to Dynamically Build Complex Queries with Composed Scopes

In previous posts, I wrote how to build complex search queries in Rails 2 using the ez_where plugin. In Rails 3, such plugins and long-winded code is completely unnecessary thanks to the powerful ActiveRelation query interface.

Lightweight Web Apps: Getting Started With Sinatra

For many reasons, I’m a huge fan of Rails for building web software, and by implication, coding in Ruby. When you’ve spent a little time working with Ruby, it’s difficult to go back to more traditional languages such as PHP.

Run Rails 3 Apps on Passenger

Update: Make sure you update Rubygems using sudo gem update --system.

Rails: Getting the id of form fields inside a fields_for block

Something that seems to crop up a lot when working with nested forms is the need to access the id of an input field generated inside a fields_for loop. The problem is that the FormBuilder object doesn’t expose its index attribute, so you can’t specify the full id of the field. For example:

Rails: Writing library code

Plugins are great in Rails, but sometimes they seem a bit much for certain tasks, such as writing a quick utility mixin. In a previous post on writing DRY validators, I discussed putting the validation mixin code inside Rails’ config/initializers directory.

Rails: Configuring RSpec for Spork

RSpec is great for behaviour driven development in Rails. However, as the amount of code you test increases, so too does the time taken to run the tests.

Rails: Abstract Models - ActiveRecord Without Tables

I recently hit a situation where I needed an ActiveRecord model with no corresponding database table. The model had to represent a collection of other event-type models - for example: Birthdays, Weddings, Anniversaries, etc.

Rails: Building Complex Search Filters with ActiveRecord and ez_where

With the release of Rails 3, the plugins and code described below no longer works. Read the updated post on building dynamic complex queries with composed scopes.

Rails: Building Complex Search Filters with ActiveRecord and ez_where - Part 2

With the release of Rails 3, the plugins and code described below no longer works. Read the updated post on building dynamic complex queries with composed scopes.

Rails: Building Complex Search Filters with ActiveRecord and ez_where

With the release of Rails 3, the plugins and code described below no longer works. Read the updated post on building dynamic complex queries with composed scopes.

Rails: Retaining select_tag's Selected Option

Working with Rails’ select_tag helper to build a search form, I needed to retain the user’s selected value after a form get, and was using the options_for_select helper:

PHP: Fixing Mismatched Canaries - How to Remove suhosin from Debian/Ubuntu Packages

30 August 2009: Will’s comment notes that Debian Squeeze now has an updated php5-suhosin package that may fix the problem I discuss below.

Rails: Upgrading test_helper.rb for Rails 2.3

Keen to be using the latest code and features of Rails, I installed Rails 2.3 for development today. So far, most of the app has worked fine after a running a rake rails:update. However, today I came across an error when running my unit tests: