Short circuiting partials


This post is by Daniel Wanja from onrails.org


Click here to view on the original site: Original Post




I tend to think of partials as mini-components. I don’t like it when the page using the partial “knows” too much about what’s in the partial. For instance, if your partial displays a collection of things but shouldn’t display anything if the collection is empty, then you’ll usually see something like this:


outer page stuff…
<% unless some_object.has_many_things.empty? %>

My collection of stuff

<%= render :partial => ‘my_partial’, :locals => { :collection_of_stuff => some_object.has_many_things } %>
<% end %>
more outer page stuff…

The outer page has to know which collection of things the partial is going to use and performs some display logic around that. Shouldn’t this all be contained in the partial? The outer page should just know that it is going to use a partial and that’s it. So our outer page will look like this:


outer page stuff…
<%= render :partial => ‘my_partial’, :locals => { :some_object => some_object } %>
more outer page stuff…

Now it looks like a self-contained component. Good. Of course, we now have to put that outer display logic in the partial.


<% unless some_object.has_many_things.empty? %>

My collection of stuff

<% some_object.has_many_things.each do |o| %>
do some stuff with <%= o %>
<% end %>
<% end %>

Now the messy part is the big unless block around the whole partial. I’d like to just short circuit the whole page if there’s nothing to display, similar to what I do in normal methods:


def do_something(some_arg)
return nil unless some_arg
do_something_cool_with_some_arg
end

Can it be as simple as putting a return statement in our partial? It turns out, yes, it is that easy.


<% return if some_object.has_many_things.empty? %>

My collection of stuff

<% some_object.has_many_things.each do |o| %>
do some stuff with <%= o %>
<% end %>

Wow! One whole line shorter. It doesn’t look like much in this small contrived example, but I think it makes the purpose of the partial clearer and doesn’t clutter up the calling page. Give it a shot.

Dreamhost out, Slicehost in.


This post is by Daniel Wanja from onrails.org


Click here to view on the original site: Original Post




I must say I like Dreamhost but we had too much downtime recently. Even if we offer time.onrails.org for free it must be up and running when the users need it. This is especially true for a time management application. When you are done with your workday, one click and go home. Lee and I are using time.onrails.org daily for all of our customer projects and recently it has been down once too many time. In addition it’s getting really slow, but then again with a $9 a month shared host plan, I must admit we went already a long way. So time to move on and find a better solution.

We went the last two days on the search for a new hosting provider that would provide dedicated or virtual private servers. There is lots of offerings out there and good information. Lee stumble upon slicehost.com and liked the idea of a small hosting company, that diggs Ruby on Rails, and is about to be launched. They are small and hopefully will work hard to make it. I was not too convinced so we decided to contact them, and had a nice chat with them over their campfire support room. See the campfire transcript. I gave them a hard-time, but they provided us with lots of good information. Check them out if you want to find out what’s going on at slicehost

Transcript: http://onrails.org/files/20060804_slicehost.html

So time.onrails.org users, thank for your patience. In the next month we will move over our application to a way faster environment.

Update: time.onrails.org has been moved. If you sign up with slicehost because of us, feel free to say we referred you. ๐Ÿ™‚ Just use this referrel link.

Shugo Maeda – Ruby on Rails Podcast


This post is by Ruby on Rails Podcast from Ruby on Rails Podcast


Click here to view on the original site: Original Post




A report from RailsConf with Japanese developer Shugo Maeda. Translated by Stephen Munday.

Shugo Maeda – Ruby on Rails Podcast


This post is by Ruby on Rails Podcast from Ruby on Rails Podcast


Click here to view on the original site: Original Post




A report from RailsConf with Japanese developer Shugo Maeda. Translated by Stephen Munday.

RailsAnalyzer – visualize your Ruby on Rails production log


This post is by Daniel Wanja from onrails.org


Click here to view on the original site: Original Post




Download Application:
User Guide

RailsLogAnalyzer รขโ‚ฌโ€œ help wanted


This post is by Daniel Wanja from onrails.org


Click here to view on the original site: Original Post




I need some Mac users to test and give feed back on a very early version of the RailsLogAnalyzer. This app is an OSX app and not deployed on a server, so I would like to find out the obvious bug that may occur on different Macs. I tried it on my own MacBook Pro, G5 server, and on an old PowerBook G4. But then again the people most likely to use it are Rails developers that may have differences in their environment.

So if you like to take risks :-), understand the basic structure of a Rails app, have a production.log you want to analyze, and are not afraid of some scary bugs then read on…

Scott Barron – Ruby on Rails Podcast


This post is by Ruby on Rails Podcast from Ruby on Rails Podcast


Click here to view on the original site: Original Post




The founder of the Rails Podcast muses about acts_as_state_machine, running a business, and keeping up your Rails face.

Scott Barron – Ruby on Rails Podcast


This post is by Ruby on Rails Podcast from Ruby on Rails Podcast


Click here to view on the original site: Original Post




The founder of the Rails Podcast muses about acts_as_state_machine, running a business, and keeping up your Rails face.

Two new eCommerce sites driven by Ruby on Rails.


This post is by Daniel Wanja from onrails.org


Click here to view on the original site: Original Post




While I was zipping a drink at the pool in Spain and visiting friends and family in Switzerland, the team at Gatelys.com was busy designing and configuring two new ecommerce stores using the Rails eCommerce platform I worked on while a Gatelys. And they have many more ecommerce sites to come.

www.sleekspaces.com and
www.raysgolfshop.com

Rails is open for some serious business.

Note that most of the logos, graphics and layouts are done by Lomax which is the best graphic designer I know. Now if only I could find a way to hire him away ๐Ÿ™‚



This complements www.nationaltabletennis.com that was launched a couple of months ago:

Fowler on RubyGems


This post is by Daniel Wanja from onrails.org


Click here to view on the original site: Original Post




Since Daniel came back from Europe, I figured I’d finally pick up his slack and write an entry. ๐Ÿ™‚


Last night I went to the Boulder-Denver Ruby Group where Chad Fowler spoke about all things RubyGems. It was a laid back talk with a recap of gems past, present and future. Pre-RubyConf 2003 the ruby-talk list would get peppered with questions like “Where is Ruby’s CPAN?”

At RubyConf 2003, when put on the spot by David A. Black about the topic, Matz basically said "if you build it, it will be included in ruby core. That led Jim Weirich, Rich Kilmer, Black, and Fowler to spend the next night coding what would become the RubyGems. They even demo-ed it at the conference. It has grown quite a bit since then and now could be called the de facto standard for library distribution in Ruby.

The latest version of RubyGems is 0.9.0, which has some not so minor scalability improvements. To get the latest version simple run gem update --system. Since RubyGems isn’t in core yet, you still need to require 'rubygems' or set your RUBYOPT environment variable to rubygems. There is another way when starting ruby you can pass it the -rubygems argument. “But you said it wasn’t in core… if it’s not in core, why does it have it’s own argument for the ruby interpreter?”"

It’s true, it’s not in core. This is actually just a little trick by Chad et al to make it look it is part of ruby. The -r argument tell ruby to require whatever parameter follows, so the gem crowd made an ubygems.rb file that only has one line of code in it … require ‘rubygems’ … and from that comes ruby -rubygems.

Bundled with gems is its own gem_server. Firing this up starts up a WebBrick server on port 8808 by default. Going to http://localhost:8808 will then display all of the gems you have installed and even link to the rdoc installed locally if it exists and to the docs on the web. It also can serve gems if you wish. This means other machines could point to your gem_server and install any of the gems that you have installed. You do this with the --source argument. Others could search what gems you have by running gem search -r --source http://your_machine:8808 search_string. There is even a tool index_gem_repository.rb that will create a directory that can be served by apache as a gem server, in case you want something a little beefier than webrick.

One interesting idea that Chad mentioned was making a meta-gem for your projects. All the gem would declare is its dependencies on the other gems that your project needs. That way when setting up a new machine you can just install your meta-gem from your gem_server and then it will automatically install all the necessary gems. Pretty cool.

Chad did a good job of describing how gems came to be and guiding us through some of the code with some nice anecdotes along the way.


P.S. The coolest part of the night was I’m going to be a volunteer at RubyConf `06! Chad was quick to warn me that there is no glamour involved. Oh well, I’m excited anyway.

Adrian Holovaty – Ruby on Rails Podcast


This post is by Ruby on Rails Podcast from Ruby on Rails Podcast


Click here to view on the original site: Original Post




The lead developer of the Django framework shares his perspectives on solving the problems of website development.

Adrian Holovaty – Ruby on Rails Podcast


This post is by Ruby on Rails Podcast from Ruby on Rails Podcast


Click here to view on the original site: Original Post




The lead developer of the Django framework shares his perspectives on solving the problems of website development.

RailsConf 2006: Marcel Molina and Sam Stephenson – Ruby on Rails Podcast


This post is by Ruby on Rails Podcast from Ruby on Rails Podcast


Click here to view on the original site: Original Post




Hear about integration tests, optimization, and the tumblelog from Sam Stephenson (creator of Prototype, Rails core, 37signals) and Marcel Molina (Rails core, 37signals).

RailsConf 2006: Marcel Molina and Sam Stephenson – Ruby on Rails Podcast


This post is by Ruby on Rails Podcast from Ruby on Rails Podcast


Click here to view on the original site: Original Post




Hear about integration tests, optimization, and the tumblelog from Sam Stephenson (creator of Prototype, Rails core, 37signals) and Marcel Molina (Rails core, 37signals).

June – Rails Month


This post is by Daniel Wanja from onrails.org


Click here to view on the original site: Original Post




June was one of these ‘Rails’ month…With Lee we took on a new Rails project in the e-learning arena for some people with some really cool ideas. They wanted a html prototype at the end of the month, and overly optimistic as I am, I said why just a prototype, let’s build the real thing. And we did. Now there is more to the application before it can go life than what we just build, but we managed to go from concept to a real working front-end in an extremely short time. Wired frame UI, intense object modeling discussions, html prototype, then build it with Rails. Rails just get’s out of your way and let’s you build a web application as fast as your brain allows ๐Ÿ™‚ We where really surprised how fast a great application can be build. This was only part time, as my main project is working on gatelys.com new ecommerce platform. An astonishing Rails application. I also worked a little on RailsLogAnalyzer, a ‘Rails production log’ visualization application using Rails and Flex on OSX. But for that one I will wait that the Flash Player 9 is out for OSX Intel. Then RailsConf 2006. That was awesome, meeting 700 Rails enthusiasts, the Rails core team, and many Rails developers from the Denver area. I can just say: “Rails has a bright future!”. But now is time for me to sit back, relax. I’ll be on vacations for most of July. So see you then!

Pickin’ up the slack


This post is by Daniel Wanja from onrails.org


Click here to view on the original site: Original Post




I guess I’ll have to try to pick up the slack while Daniel’s trekking around Europe. In case you don’t know, I’m the guy named Lee that Daniel mentions from time to time.

Hopefully, I’ll be able to fill some space here with some useful tidbits about Rails, Ferret, and whatever else looks interesting.

Have a great vacation, Daniel. We’ll leave the light on for ya.

Streamlined – Will ROCK the Rails World


This post is by Daniel Wanja from onrails.org


Click here to view on the original site: Original Post




Streamlined is an open source framework for quickly creating data-centric applications with Ruby on Rails.
Today Justin Gehtland announced during his ‘Ajax on Rails’ talk that Streamlined will be released at OSCON in July. I can best describe Streamlined as ‘dynamic scaffolding’ done right. Streamlined is a model driven way of generating data centric UI’s. Justin demoed how to create and modify a data entry application. It provides search, crud functionality, support relationship between model, and way more. The framework adheres to the convention over configuration approach and provides a default behavior of the application than can easily be refined and enhanced. As opposed to scaffolding it doesn’t generate code for the controller but provides a basic behavior. This will ROCK the software development world and accelerate many projects.

From the Streamlined website:

In the Abendsen release, Streamlined has been focused on solving the problems of our customers and our internal projects. Right now, Streamlined is focused on:

  • Generator for churning out the initial views and configuration
  • A declarative DSL for managing views, including relationship management, field selection, etc.
  • Full Ajax-enabled management views with sorting, paging and live search (with configurable field-inclusion)
  • A criteria query extension to Active Record
  • Context-sensitive help
  • An extensible component system for representing relationships at runtime
  • Export to xml/csv
  • REST-ful web service layer around all models
  • Atom support
  • Auto user-management and inclusion of declarative role-based authorization
  • Choice of layouts (Yahoo Grids or CSS Framework)
  • Theme support
  • Includes Javawin for in-browser windowing

This is the feature set we’ll release at OSCON in July.

RailsConf 2006 – Here we come!


This post is by Daniel Wanja from onrails.org


Click here to view on the original site: Original Post




Looking forward meeting you all in Chicago! There will be tons of great presentations, here is my selection:

Friday
10:45 Introduction to Capistrano
Mike Clark is just a great presenter
13:15 ??
Not sure yet
14:30 Monitoring Rails Applications in Production Environments
Too important to skim that one
15:45 Sneaking Rails into the (legacy) system
or Goeffrey’s Rails Deployment on Shared Hosts
Saturday
09:00 Ajax on Rails
Let’s see what the ‘man’ has to say
10:15 Lessons from Blinksale and IconBuffet
I am eagerly waiting for some information on the Blinksale API
11:30 Lucene Eye for the Ruby Guy
We are using successfully Ferret, but Lee did all the programming, so it’s time I do some catching up
14:45 Testing Migrations
I hesitate between this and the two other talks, but I got bit a couple of time with migrations. So any good advice is welcome.
Sunday
9:00 Beyond DHTML: Introducing Laszlo on Rails
I am big fan of Flex and Laszlo, now that Laszlo can generate DHTML, let’s see what Mike has to say.
10:15 Just the Facts (and Dimensions) — using Rails with your OLAP data model
I had the chance of beeing part of a team that pionered the field before it was called that (back in 1987). And now I need to do some more data analysis for the soon to be releases OSX RailsLogAnalyser application (Flex+Rails). Looking forward to this talk.
11:30 Rails Takes on the Enterprise with SOA
Rails is a tuff sell to the enterprise. They invested to much into Java and .Net, so even if Rails is often a good fit, it’s not even considered. So any additional ammunition to enter existing enterprises is welcome

Josh Susser – Ruby on Rails Podcast


This post is by Ruby on Rails Podcast from Ruby on Rails Podcast


Click here to view on the original site: Original Post




Newly knighted Rails blogger Josh Susser muses on database relationships and reliable apps.

Josh Susser – Ruby on Rails Podcast


This post is by Ruby on Rails Podcast from Ruby on Rails Podcast


Click here to view on the original site: Original Post




Newly knighted Rails blogger Josh Susser muses on database relationships and reliable apps.