AssetPackager Tracker 13
Asset Packager now has a tracker where you can submit tickets. You can find it here.
If you have a bug to report, and/or a patch for Asset Packager, this is the place.
WeoGeo - AWS Startup Challenge Finalist 5
My company WeoGeo made it to the final round of the Amazon Web Services Startup Challenge. In the top 7 out of around 1000 entrants, not too shabby.
Check out the videos for the finalists, and vote for WeoGeo!
RubyBrigade.org - A Rails Rumble Success 14
Just wanted to mention our Rails Rumble project, RubyBrigade.org. Jason Perry, James Seaman and I worked through the weekend to build RubyBrigade.org – a geographically aware database of Ruby User groups.
Big thanks to James for the killer hand drawn illustrations and interface. Big thanks to Jason & Katie for letting us take over their house for the weekend.
Features:
- Google Maps Integration
- Sub-domains for each group
- Geocoding: either by the search box or by sub-domain!
- RSS and iCal feed parsing
- Display latest user groups
- Display upcoming events across all groups
- Display blog posts & upcoming events for individual groups
- ReCAPTCHA for spam prevention
- No authentication required
More Screenshots
View a Brigade
Edit a Brigade

Delete a Brigade

404 Message
If you like what you see, vote for us!
Redesign RubyForge? 9
With the whole RailsForge survey thing, it’s also come out that a lot of people hate the current incarnation of RubyForge.
Some are suggesting to redesign RubyForge, which is a good idea. Re-think RubyForge and give it some 37signals-style, UI-first design love. I haven’t talked with any RubyForge maintainers yet, but I’d be interested in helping out.
By the way, I totally appreciate RubyForge, and I’m so thankful to the people who run it and donate their time and money to keep it going.
RubyForge pet peeves
What is it about RubyForge that’s so annoying? For me, when I arrive at a project page on RubyForge, I’m greeted with a plethora of “stuff” cluttering the page, that’s either un-used or not really telling me anything. I often leave more confused, and I’m an experienced developer. Imagine how a beginner feels! I then look elsewhere hoping someone has written a helpful tutorial on their blog.
RubyForge-specific complaints from the RailsForge survey responses:
- Most of the features go unused.
- Biggest problem is the UI.
- It’s very difficult to do the things the majority of people want – 1. learn about a project, 2. download and install it, 3. learn how to use it.
- 90% of the project page has nothing to do with any of this and it just adds clutter.
- Let project maintainers selectively turn on the features they want.
- 80% want to learn. 20% want to contribute. Refocus the UI to reflect this.
Yes, RailsForge! 14
I’m part of a small team tossing around ideas for a RailsForge.
Surveying the community
Jason Perry chose to survey the community and get some discussion going before anything was built. That’s been interesting. We’ve already received a lot of feedback – tons of positive, some negative, and some generous offers of help.
Since there’s nothing to see yet, and 90% of stuff produced these days is crap, some people automatically assume you too will build crap and yell “NO!” Some of it is along the lines of “don’t duplicate RubyForge” or “don’t fragment the community.” And we’ve all pretty much agreed we don’t want to. We’re not going to host source code or gems on RailsForge. Although its still a question on the survey, because Jason still wants to know what you think.
The big idea
Think of RailsForge as a view of the ruby community that’s central to rails development, with the hope of making things easier to find, learn, and discuss. More like a Technorati for Rails projects, but not so much svn/trac/tickets. We’ll leave that to existing facilities like RubyForge. We want to keep that and build a community focused site on top of it. We’re still letting the ideas percolate for a few more days. Feel free to contribute.
We’ll then go quiet for a month or so and build something. ;)
RubyForge
What about RubyForge? It could use some love too! More on that in another post.
Are you SURE?! (How to confirm HTTP methods in Rails) 14
In Scott Raymond’s excellent book Ajax on Rails I came across a cool (non-ajax related) pattern for insuring a request’s method is POST and showing a confirmation form if not.
This is really useful in situations such as confirmation links in emails, where a form can’t be displayed and javascript won’t work, yet we don’t want a destructive action occurring through a GET request.
Here’s an example:
def unsubscribe
if request.post?
@user = User.find(params[:id])
@user.update_attributes :subscribed => false
redirect_to home_url
else
render :inline => %Q(
<% form_tag do %>
<%= submit_tag 'Confirm' %>
<% end %>
)
end
endOne other piece of code you’ll need to get this to work, assumming you’re using RESTful routes, in config/routes.rb
map.resources :users, :member => {:subscribe => :any,
:unsubscribe => :any}This states that we have a couple extra actions in our controller, and we’re not going to mandate a specific HTTP method to get there. This way we can handle it within the action if the HTTP method is wrong.
Now if your user comes to your page from a straight GET request, he’ll get prompted to confirm the big destructive action he’s about to commit.
(In a real app we’d make this form look a bit nicer.)
Wouldn’t it be nice if we could re-use this pattern, without writing out the inline form code every time? Seems generic enough.
DRY it up!
We could abstract that out, and also support any HTTP method we want. Lets follow Rails / RESTful conventions , and require PUT for updating a model. Using some handy ruby block syntax, we could write something like, say:
def unsubscribe
confirm_unless :put do
@user = User.find(params[:id])
@user.update_attribute :subscribed, false
flash[:notice] = "User is now unsubscribed"
redirect_to users_url
end
endMuch better. But how?! Keep reading.
Get one for yourself!
To get the confirm_unless method for yourself, slap the following code into app/controllers/application.rb:
def confirm_unless(method)
if request.method == method
yield
else
render :inline => %Q(
<% form_tag({}, :method => :#{method}) do %>
<%= submit_tag "Confirm" %>
<% end %>
)
end
endWe could take it one step further and make it a before_filter, but I’ll leave that for a possible future post.
How to generate CSV files in Rails 11
A while back someone posted on rubyonrails-talk asking how to export to CSV from Rails. I posted a solution, and people seemed to dig it, so I’ll share it again here.
Use FasterCSV
Get the FasterCSV gem. Why? It’s faster, and easier to use. Once you’ve got it, require it in environment.rb. Here’s an abbreviated version of my working controller method. Copy/paste/modify. And you’re done!
def export_to_csv
@users = User.find(:all)
csv_string = FasterCSV.generate do |csv|
# header row
csv << ["id", "first_name", "last_name"]
# data rows
@users.each do |user|
csv << [user.id, user.first_name, user.last_name]
end
end
# send it to the browsah
send_data csv_string,
:type => 'text/csv; charset=iso-8859-1; header=present',
:disposition => "attachment; filename=users.csv"
endHTML or CSV, have it your way
Now, if we wanted to get all clever about it, we could go further and serve both html and CSV data with only one action, using respond_to. This also requires that you add a RESTful route (map.resources :users) to your routes.rb file:
def index
@users = User.find(:all)
respond_to do |wants|
wants.html
wants.csv do
csv_string = FasterCSV.generate do |csv|
# header row
csv << ["id", "first_name", "last_name"]
# data rows
@users.each do |user|
csv << [user.id, user.first_name, user.last_name]
end
end
# send it to the browsah
send_data csv_string,
:type => 'text/csv; charset=iso-8859-1; header=present',
:disposition => "attachment; filename=users.csv"
end
end
end
Now if the user requests:
/users she’ll get HTML. If she requests:
/users.csvYou get the point.
Random Permutation in Ruby 10
This post on Algo Blog about random permutation shows a cool a little algorithm for randomizing an array which apparently impresses interviewers. I thought it might be fun to write it in Ruby:
def permute_array(a)
1.upto(a.length - 1) do |i|
j = rand(i + 1)
a[i], a[j] = a[j], a[i]
end
a
end
# alternate version
def permute_array2(a)
0.upto(a.length - 2) do |i|
j = rand(a.length - i)
a[i], a[j] = a[j], a[i]
end
a
endThis is actually a pretty fun little function to use. For example – to find all the unique possible combinations of letters in my name: (Secret Scrabble weapon)
# Generate an array of 5000 randomized versions of the letters
# used in my name. Filter out the unique ones and sort it.
# Did I really need to comment this?
(1..5000).map{ permute_array("scott".split("")).join }.uniq.sort
=> ["costt", "cotst", "cotts", "csott", "cstot", "cstto", "ctost",
"ctots", "ctsot", "ctsto", "cttos", "cttso", "ocstt", "octst",
"octts", "osctt", "ostct", "osttc", "otcst", "otcts", "otsct",
"otstc", "ottcs", "ottsc", "scott", "sctot", "sctto", "soctt",
"sotct", "sottc", "stcot", "stcto", "stoct", "stotc", "sttco",
"sttoc", "tcost", "tcots", "tcsot", "tcsto", "tctos", "tctso",
"tocst", "tocts", "tosct", "tostc", "totcs", "totsc", "tscot",
"tscto", "tsoct", "tsotc", "tstco", "tstoc", "ttcos", "ttcso",
"ttocs", "ttosc", "ttsco", "ttsoc"]More RejectConf Videos 1
From the ever-helpful Dr. Nic.
RejectConf2007 Videos 2
Found a couple videos from RejectConf, which I missed out on while at RailsConf. And since there was 4 parallel tracks at RailsConf, the most anyone could see is 25% of it. If anyone knows links to more videos from RailsConf07 or RejectConf07, I’d love to know.






