Rails Sitemap

“When something is too hard, it means that you’re not cheating enough. it means that you’re doing it wrong“. Generating a Rails sitemap (hash of application controllers and actions) is as simple as placing and calling this method in your application: 1234567891011121314 def controllers_and_actions require ‘find’ site_map = {} Find.find(RAILS_ROOT + ‘/app/controllers’) do |file_name| if /_controller.rb$/ =~ file_name name...

Rails – multi selects for associated models

Handling Multiple Selects (or multiple associated attributes) can be quite cumbersome. Ryan Bates has recently wrapped it very nicely in his Complex Forms Screencast. As per that simple way, here’s a how I handle it: Model: 1234567891011class Project < ActiveRecord::Base….has_many :assigned_taskshas_many :users, :through => :assigned_tasks….def assigned_task_attributes=(assigned_attributes)assigned_attributes.each do |attributes|assigned_tasks.build(attributes)endendend Controller:def create @project_task = ProjectTask.new(params[:project_task]) @project_task.save New/Edit Views:<%= select_tag(“project[assigned_task_attributes][][user_id]”, options_for_select(@users.collect{|u| [u.full_name,...

Blueprint-CSS

After using the CSS Framework from Content-with-style for a few years, I grew tired of how it’s structured, and how difficult it is to customize. Along came Blueprint-CSS. A great concept, and wonderful implementation. And with the new BlueprintCSS Generator plugin for Rails from Ariejan.net, how can I resist using it. I’m rolling it out in my current project...

AnyKey FF Plugin

For those of us who are Arabic-typing challenged (picking up Arabic letters off the keyboard) – AnyKey is the solution. AnyKey is a FF plugin that gives you the power of writing Arabic as it sounds (without the need to learn the Arabic keyboard layout). It also got transliteration from “Russian, Ukrainian, Amharic, Armenian, Hindi Davangari, Hebrew, Mongolian, Greek,...

irb and rails console tab completion

By chance, irb and ruby-console tab completion discovery. Made my day!irbirb(main)> t = Time.new => … irb(main)> t.m #[tab] t.mday t.method t.methods t.min t.mon t.month Rails Console>> Feed.fi #[tab] Feed.find Feed.find_all Feed.find_all_with_deprecation Feed.find_all_without_deprecation … Win XP, ruby 1.8.5 and rails 1.2.2. Google away if not on your machine. irb is incredibly underappreciated, it has a bunch of nice things...

Pyramids, Application. An Analogy

Working on maintaining and modifying a five year-old Java application, I came to realize there’s a strong relation between legacy and pyramids. Here’s an analogy: | Pyramids are HUGE monuments, built for the sole purpose of being a tomb to one person. Although the project tree is HUGE (14000+ files), the purpose of the application is amazingly modest (CRUD...

:finder_sql – single vs double quotes

This is the trickiest part of Rails I came across so far:In my has_many association I have a finder_sql that should reference the instance object id rather than the class object id. has_many :breedtypes, :finder_sql => ‘SELECT Breedtype.* FROM … WHERE (cai = #{id})’ Now, who’d ever have thought that replacing the “double” quotes I had wrapping the “Select”...

2D to 3D Innovation from Fotowoosh

The most innovative imaging service I’ve seen since Riya and Photosynth. Fotowoosh, a real innovation, through Freewebs. The service (currently in alpha) takes your regular 2D images and transfers them into 3D ones automatically. </embed> I guess this makes freewebs a very good buyout candidate to <place_your_favorite_company_here> via TechCrunch