RailsLogVisualizer: now open source and 6 x faster.

This post is by Daniel Wanja from onrails.org

Click here to view on the original site: Original Post

I moved the RailsLogAnalyzer to RubyForge and as there was already a project on RubyForge with the same name, so I renamed it to RailsLogVisualizer. So RailsLogVisualizer it is. Version 0.3 provide a drastic speed improvement over version 0.2. If you are curious or adventurous you can browse the source code on RubyForge.

The Project Home Page is http://railslogvislzr.rubyforge.org/
The project is at http://rubyforge.org/projects/railslogvislzr/

EdgeCase – 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 chat with the members of EdgeCase, a Ruby consulting firm in Columbus, Ohio.

EdgeCase – 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 chat with the members of EdgeCase, a Ruby consulting firm in Columbus, Ohio.

The Rails Edge Conference in Denver – Day 3

This post is by Daniel Wanja from onrails.org

Click here to view on the original site: Original Post

I am a bit late (20minutes) to the conference as I had an iChat with my nieces that turned 3 today.

THE RAILS TIMES by Mike Clark and Bruce Williams

So I seems I haven’t missed to much so far. Mike Clark and Bruce Williams are presenting what’s new in Rails. They call it it “THE RAILS TIMES”, and the first slide is a news paper front page.

  • HABTM Ousted in favor of Rich Models using has_many :through.
  • Many deprecations telling you how to prepare for Rails 2.0.
  • Routes get named.
  • Extra: Ruby generates javascript. page[:tags].reload # reload tags.rhtml partial.
  • Serial(ization) Killers At Large: YARML, XML, JSON
  • RSS is the next big thing: render_rss_feed_for(@people, options)
  • The future is CRUD: ruby script/generate scaffold_resource article. map.resources :articles
  • Conventions Flourish: see simply_helpful. form_for @person do end
  • BULLTIN: Apps respond-to Clients: respond_to do |format| format.html, format.js, format.xml, format.yaml. Custom format can also be added.
  • CORBA? RMI? No, ActiveResource!: class Person < ActiveResource::Base
  • Security Alert! Parameter Filtering – filter_parameterlogging :password, :login, :user
  • Installation Typo Triggers Global App Meltdown: rake rails:freeze:gems
  • Manking Attacked by Mongrel: gem install mongrel
  • Tomorrow’s Edition? : Rails 2.0? REST?

The Meaning of CRUD by Chad Fowler

This is an awsome talk where Chad is going into the impact that a RESTFul approach has on your development and how to write your application using the new named routes and RESTfull controllers.

Streamlined by Justin Gehtland
Justin goes through many of the options on how to manipulate declaratively a Streamlined driven UI.

Road map:

  • 0.0.6 new look (soon)
  • 0.0.7 control types for fields
  • 0.0.8 plugin instead of generator
  • 0.1 99% rcov, compatibility

Features to look for

  • visual configuration
  • declarative tabbed ui 0.0.8?
  • generated columns sortable
  • context specific ui (different for list, show , edit…)
  • rich text editor (TinyMCE)

Deployment by James Duncan Davidson

Start Early deploying your applications. Find all the “interesting” deployment problems up front. You’ll know how to do it when the times comes. You’ll get into the deployment rhythm.

How to do it: not using WEBrick, CGI, FastCGI…but proxy to Mongrel (ya-huh!). Front End use Apache, Lighttpd, Pound, Pen, or hardware load balancer. Use Capistrano. The Golden Path assumes Capistrano, Unix (NOT Windows), subversion. Apache 2.2.x (myproxy balance), Ruby Termios Library, MySQL 5. Duncan then went on to a live demo, connected to his Subversion repository in Portland using the Hotels network deploying to an EC2 (Amazon Elastic Computing Cloud) . So pretty gutsy demo but the demo went on pretty well.

Awesome conference, well worth the money. Not only was it well organized but the talks where just loaded of useful information. Thanks to all the presenters!

Rake Command Completion Using Rake

This post is by Daniel Wanja from onrails.org

Click here to view on the original site: Original Post

This is an update of a previous post.

I just watched Jim Weirich’s talk on Rake at the Rails Edge Studio and decided to update the command completion script to use Rake itself for caching the tasks. Err the Blog did an update on my script last month to include caching for a nice speedup, so I took that and made sure the cache is regenerated when the Rakefile or any rake tasks found in your rails app have been updated. I added this with just some straight ruby code, but Jim’s talk made me realize that this type of thing is exactly is what rake is for. So, here is the updated version:

#!/usr/bin/env ruby

# Complete rake tasks script for bash
# Save it somewhere and then add
# complete -C path/to/script -o default rake
# to your ~/.bashrc
# Nicholas Seckar nseckar@gmail.com
# Saimon Moore saimon@webtypes.com
# http://www.webtypes.com/2006/03/31/rake-completion-script-that-handles-namespaces
# http://errtheblog.com/post/33

exit 0 unless File.file?(File.join(Dir.pwd, ‘Rakefile’))

require ‘rubygems’
require ‘rake’
DOTCACHE = File.join(File.expand_path(‘~’), “.rake_task_cache” , Dir.pwd.hash.to_s)
RAKE_FILES = FileList[ FILE, ‘Rakefile’, ‘lib/tasks//.rake’, ‘vendor/plugins//tasks//*.rake’]
tasks = rake --silent --tasks.split(“n”).map { |line| line.split[1] }
require ‘fileutils’
dirname = File.dirname(DOTCACHE)
FileUtils.mkdir_p(dirname) unless File.exists?(dirname)
File.open(DOTCACHE, ‘w’) { |f| f.puts tasks }

tasks = File.read(DOTCACHE)

exit 0 unless /brakeb/ =~ ENV[“COMP_LINE”]

after_match = $’
task_match = (after_match.empty? || after_match =~ /s$/) ? nil : after_match.split.last
tasks = tasks.select { |t| /^#{Regexp.escape task_match}/ =~ t } if task_match

# handle namespaces
if task_match =~ /^([-w:]+:)/
upto_last_colon = $1
after_match = $’
tasks = tasks.map { |t| (t =~ /^#{Regexp.escape upto_last_colon}([-w:]+)$/) ? “#{$1}” : t }

puts tasks
exit 0

Update: I fixed the bug that janfri pointed out. The bug caused the first task to be missed. I also changed it so it won’t abort if rake isn’t the first command on the command line. This will allow stringing multiple commands together. For instance:

rake db:migrate VERSION=0 && rake db:migrate


The Rails Edge Conference in Denver – Day 2

This post is by Daniel Wanja from onrails.org

Click here to view on the original site: Original Post

He we go again, day 2 is starting.

Rails the right tool for the job? by Mike Clark.
Mike will address the following aspects of Rails:Sweet spots, Honey Pots, Tar Pits. Rails is a full-stack web framework, no need to choose the different parts of the stack it’s ready to go from the start. It’s Quick and Clean, like Martin Fowler would say. Mike adds quicker than J2EE and cleaner than PHP. The sweet spot: database backed web applications, green-field development, open-minded team, following the rails way.
Honey Pots is when you get into Rails because it’s sweet, but then you get stuck. In other words the not so sweet spots: Legacy, Internationalization, messaging systems, heavy use of threading.Tar Pits two phase commits, off the shelf components, obfuscation, client installations, corporate standards.

Active Record Demystified by Marcel Molina Jr.

An in-depth tour of connection adapters, ActiveRecord::Base#save, and ActiveRecord::Base.find.

Building UI Frameworks by Bruce Williams.
Bruce worked on a large system with many views. Views are tedious and are time consuming to develop and took a large portion of the development of the 90000 Ruby code application they wrote. I will not talk about components, engines, markaby. Bruce will shares some of his frustrations and challenges. Views are hard to read, are hard to learn (ruby, rails, html, css, javascript+prototype). He extensively explain the difficulties that are faced when doing view development and mentions that it’s all about Pain Management.. He continues by showing some examples and concepts to ease that pain by using simply_helpful plugin, DSL for controllers, and block helpers than render partials.

Rake Your Secret Weapon by Jim Weirich.

Burried Treasure by Dave Thomas
Tips and Tricks for Ruby & Rails Development. Dave goes through these following Rails goodies:

  • with_scope
  • with_options
  • returning
  • &:xx – The Blockinator %w{ cat dog }(&:upcase) or users.map(&:name)
  • Lookup Constants
  • Formatting dates and number
  • Enumerable extensions (i.e. group_by)
  • Arrays: in_groups_of, to_sentence
  • Strings: at, from , to, first, last, each_char
  • Subversion integration: script/generate model mymodel –svn (adds it automatically to subversion)
  • The Console: app.get, app.response, helper, irb for default object, ActiveRecord::Base.logger = Logger.new STDOUT
  • Routing: >>irb ActionController::Routing::Routes; puts routes
  • TextMate: ctrl-h on a method to shows the rdoc. ctrl-shift-apple-s on an ActiveRecord shows the schema information. Code Completion.

Ruby binding

This post is by Daniel Wanja from onrails.org

Click here to view on the original site: Original Post

What is binding? It basically holds the current state of the application… it knows what self is (or was when binding was invoked). What else does it know? I’m not sure, it’s something I’d like to investigate further. Can the binding be interrogated? Can it be manipulated?

Let me know if you have good pointers to info about it. I’ll check Pickaxe when I get home.

Module Tidbits

This post is by Daniel Wanja from onrails.org

Click here to view on the original site: Original Post

I always forget what including versus extending a Module, so here’s a little reminder for myself.

module UsefulMethods
def some_cool_thing
1 + 1 == 0

class IncludeUsefulInstanceMethods
include UsefulMethods

class IncludeUsefullClassMethods
extend UsefulMethods

puts IncludeUsefulInstanceMethods.new.some_cool_thing # => false
puts IncludeUsefullClassMethods.some_cool_thing # => false

So, including a module basically shoves the module’s methods into the class as instance methods, while extending a module puts them in as class methods.

That’s it. By the way, this was inspired by Dave Thomas’ metaprogramming talk at the Rails Edge Studio in Denver.

The Rails Edge Conference in Denver – Day 1

This post is by Daniel Wanja from onrails.org

Click here to view on the original site: Original Post

The conference just started 30 minutes ago. I will write down some notes as it moves ahead. On a side note, Chad has a cool t-shirt saying “Rails Ruby – Programmer Friendly, Enterprise Ready”…way to go, enterprise here we come.

Meta Programming Ruby by Dave Thomas.
Extending Ruby for Fun and Profit.
Meta programming allows to extend the language by writing code that writes code. This talk is about understanding how it works, but mostly it’s to allow us (the attendees) to start writing our own extensions. Dave goes through these four aspects of Ruby that enable meta programming: classes are open, definitions are active, all method calls have a receiver, classes are objects.

Ruby Idioms for Rails Programmers by Stuart Halloway
Implicit vs. Explicit – Stuart takes a Java/Struts example and refactors it to a Rails example showing along the way the explicit parts that should be implicit as they don’t have anything to do with the business logic you are trying to implement. Basically he moves a 20 lines java method down to 1 lines of ruby. This was very revealing, but let’s not start a java .vs. rails debate here 😉
Add Context to Instances – Ruby allows to modify objects to represent context. For instance active records contain the errors context that are triggered during saves, also active record contains wether it’s a new record. So breaking apart from a “pure” object model, in Rails these contexts are injected into the objects, this simplifies greatly the development concepts. For example you have on instance of Person that is valid and not new. In java these concepts are broken down in separate concepts but you end up with DAOs, validators, business object, which all need to be tied together. In short Rails is less “pure” but simpler.
Personalized Object Model – Augmentations by methods on demand (method_missing). sample platter (Symbol#to_proc, Object#with_options, and hundreds more). Domain-Specific Encapsulation – Stuart now describes how Rails provides some domain specific encapsulation to hide some of the internals of your application, i.e. hide_action, add_variables_to_assigns.
Stuart warns us that he feels strongly about the topics he will cover now, but they may be controversial. Poor Composition Disrupts Flow – Stuart refers to the Smalltalk best practice book (p22, Kent Beck) which states “…keep all the operations at the same level of abstractions…”. He diggs through some method examples form Edge Rails that could be ‘improved’.
His presentation can be found at codecite.com

Rails Reflection by Chad Fowler
Chad is presenting some of the findings of the project he workd for at Naviance. He started showing of a movie of a tool they (him and Bruce Williams) wrote to dynamically and visually create ActiveRecords and add data to it, then be able to export the fixtures. Why use Rails reflection? learn how rails work, simplify maintenance, make Rails do that Rails doesn’t do well.
Chad will go throught some of the reflection possibilities that Rails offer that allowed him to build the tool he just demonstrated.

Active Record Reflection – schema, relationships, callback and errors. Some ActiveRecord reflection examples:


Some nifty trick to run migration code from irb is when you execute the following from irb:

>>irb ActiveRecord::Base.connection

Now the receiver class (in irb) is the connection which supports migration calls like add_column, drop_table, and so on.

Action Controller Reflection – Requests, Filters, Routes.


Chad concludes with the fact that these technique should be used only where appropriate and that many applications don’t need such a level of programming.

Ruby Design Patterns by Jim Weirich

A design pattern is a solution to a problem in a context.
Jim goes in detail through some Ruby implementation of these standard patterns: Template Method Pattern, Strategy Pattern, Singleton Pattern. He also presents the Blank Slate Pattern he used while creating the XmlBuilder library.
The ruby way:

Singleton Pattern => include Singleton
Observer Pattern => include Observable
Iterator Pattern => include Enumerable
Factory Pattern => ClassName.new
Proxy Pattern => method_missing
Visitor Pattern => Open classes

Jim refers to a paper from Peter Norvig from 1996 where he categorize patterns as being Invisible, Formal, and Informal for different languages and mentions that some dynamic languages have fewer restrictions and often don’t require explicit patterns or have simpler implementations.

ActionPack Demystified by Marcel Molina Jr.

ActionPack = ActionController + ActionView
Marcel is going through the internals of ActionPack and will cover lot’s of code. So I am not sure how much I will be able to write down…I may try to follow his talk :-). Looking at the internals are useful to understand the larger story of what’s going with your application and Rails is a good example of how to write Ruby code or is a good help how to extend Rails.
Yes, he really presents lots of interesting stuff, so I’ll better sit back and follow. Right now he is explaining the compilation of the templates and going through the implementation of compile_and_render_template. Marcel want’s to see how he feels about presenting this and looks for motivation to re-implement it.

Ajax on Rails by Justin Gehtland.
This talk is about Ajax or the cool crap you can actually see. No meta programming. Justin will walk us through Prototype support in Rails, Scriptaculous Helpers, and Javascript generation.

That concludes the talks for the day. After dinner there will application presentations by the attendees.

The evening presentations where really cool
Rails Log Analyzer by Daniel Wanja. Yes, I presented the new version of the log analyzer.
Time.onrails.org by Lee Marlow. A time management application Lee and I worked on.
iDeal by Brian Spaid from mediapulse.com. A tool to quickly create websites and track user activity. This tool is used by them internally and not yet public.
RFID Tracking Software by Steve Mui. A cool rails application that allows real time asset tracking. The demo Steve presented was for an hospital that is tracking assets worth over $5000 (i.e. artificial knee) and Hospital workers. The software can track if the assets are in stock, see for specific rooms (i.e. operation room) when assets enter/leave the room. They have rfid scanners that track rfids and log their presence every couple of seconds to a Postgress database. The rails application then summarize and visualize all this data.
http://loopnote.com/ by Martin May. A topic based notification application. You can register to a topic and be notified whenever the topic maintainer notifies you of a change. Notification is by rss, email, text message. You can create your own topics. Besides be nicely designed I believe that this is going to be a pretty popular application. It’s not open to the public yet, but the demo was impressive.
showerinabox.com by Leslie A Hensley. A funny application allowing to plan a bridal shower and print out some customized bridal shower games. All in Ruby on Rails, using PDFWriter.

RailsLogAnalyzer v0.2 for OSX – Faster, Better

This post is by Daniel Wanja from onrails.org

Click here to view on the original site: Original Post

Version 0.2 of the RailsLogAnalyzer is still a development version but a great improvement over my first prototype. This version has been rewritten from the ground up and doesn’t use a database to store intermediate log file aggreation.


Analyzing your log file data.

Once the log file is loaded you will see a breakdown of your requests by year, month, and day.
Click on the year, month, or day to see the controllers invocations during that period.
Click on the controller in the chart to see the method invocations during the selected period.
The method are further broken down based on their http methods (get, post, delete, …).

Note: loading a 10Mb production log file with 30000 requests takes about 10 seconds on my MacBook Pro.
loading a 250Mb production log file with 530000 requests takes about 2 minutes.
loading a 4.5Gb production log file with 11 million request takes about 45 minutes.
The data is loaded in memory and must be reloaded once the application is closed.

Download it here RailsLogAnalyzer_0.2.dmg (487KB) and let me know your findings at daniel@onrails.org

Josh Schairbaum and Dan Manges – 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

Correspondent Robert Stevenson interviews two developers from investment banking company JPMorgan Chase.

Josh Schairbaum and Dan Manges – 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

Correspondent Robert Stevenson interviews two developers from investment banking company JPMorgan Chase.