RailsInstaller (and obligatory RailsFTW comparison)

The true successor to InstantRails is out: Wayne Sequin of RVM fame, with the help of Dr. Nic Williams and RubyInstaller‘s Luis Lavena, has just released the first version of RailsInstaller.

RailsInstaller

Now I can finally stop worrying about how to find time to maintain RailsFTW. :D

Continue reading “RailsInstaller (and obligatory RailsFTW comparison)”

My Talk on Ruby/Rails

Went to talk about Ruby and Ruby on Rails last Tuesday at the mini-DevCon at University of Perpetual Help System – DALTA. That’s the 4th public talk for this year (4.5th if you count the RailsFTW plugging last month).

No “transcript” here, though. Just imagine me giving the presentation in front of college students right after I make a class roster app in front of them in under 5 minutes, installation to demo. And yeah, Microsoft is the sponsor I was referring to in the talk.

Ruby on Windows

Some posts just write themselves. Today’s post comes from my reply to a guy in PhRUG who still thinks you need a Mac before you can develop Rails applications.

windows and ruby

This is probably the biggest problem the Ruby/Rails community has when trying to spread the word in this country: the lack of interest in supporting Windows.

I mean, a typical response to the legitimate question “I’m using Windows, how to I practice RoR?” is the fanboy answer: “Get a Mac!”

And that, my dear readers, is a dick move. If I was an average college student and you told me that, I’ll immediately think “WTF?!? I just want to try out this open-source language and web framework and I need to shell out a couple of years worth of tuition?!?

Answering “Format your hard drive and install Linux” is less of a dick move, but a dick move nonetheless.

Thus, if we rubyists want to spread the word about Ruby, we’ll have to make Windows a viable OS for Ruby development. Here are a few options available to us:

Continue reading “Ruby on Windows”

Member Route error "No action responded to"

Problem:

Member routes allow one to create additional routes to existing resources. For example, if you want to add an approve path to your purchases resource, you could do this in your config/routes.rb:

 map.resources :purchases, :member => { :approve => :put }

My problem was that the link I made for approving the purchase

<%= link_to "Approve Purchase", approve_purchase_path(@purchase), :confirm => "Proceed with approval?" %>

resulted in the following error:

Unknown action

No action responded to 1. Actions: approve, create, destroy, edit, index, new, show, and update

Cause:

Rails confused the link with a normal get operation.

Solution:

Explicitly declare the HTTP method for the action.

<%= link_to "Approve Purchase", approve_purchase_path(@purchase), :confirm => "Proceed with approval?", :method => :put %>

HTML Line Breaks in Rails Text Fields

Problem:

Rails doesn’t automatically convert newline (“\n“) characters in strings to line breaks (“<br>“) with h.

<%= h @user.address %>

Solution:

Manually replacing the \n with <br> without using h will make your site vulnerable to XSS attacks. The proper approach would be to convert the line breaks after h. Note that Rails already has a method, simple_format, that converts line breaks.

<%= simple_format(h @user.address) %>