Sebastian Delmont – Ruby on Rails Podcast

The lead developer of StreetEasy talks about bridging web 1.0 and web 2.0 for the New York real estate market.

Sebastian Delmont – Ruby on Rails Podcast

The lead developer of StreetEasy talks about bridging web 1.0 and web 2.0 for the New York real estate market.

Tom Copeland – Ruby on Rails Podcast

Take a tour of RubyForge with sysadmin Tom Copeland!

Tom Copeland – Ruby on Rails Podcast

Take a tour of RubyForge with sysadmin Tom Copeland!

Rails Log Analyzer – Rails and Flex with JSON


I started to write a small Rails Log Analyzer that provides some insight on how a given application is used. I’ve just spent three hours so far, so not too much to show, but I have found the integration of Flex with Rails for read-only purpose of the different time series pretty straight forward.

In two words…

RAILS: data.to_json

FLEX: JSON.decode(String(srv.lastResult));

On the Rails side

The controller simply transforms the Hash return by the model into a json textual representation.

class DataController < ApplicationController
def overview
render :text => Hit.overview_data.to_json
end

end

This is an extract of the method that returns a Hash that contains the time series in an Array.

def Hit.overview_data
result = {}
result[:header] = {:period => {:start => Hit.minimum(:time).to_s(:db), :end => Hit.maximum(:time).to_s(:db)}}
result[:sessions_series] =
{:by_day => Hit.data_serie(Hit.count(:session, :group => :day, :conditions => ‘controller <> “HeartbeatController”’), “sessions by day”) }
result
end

On the Flex side


import com.macromedia.serialization.json.*;
private function resultHandler(event:ResultEvent) : void
{
status = “Loaded. Parsing data…”;
var result:Object = JSON.decode(String(srv.lastResult));
header = result.header;
ts = getSerie(result.sessions_series.by_day.data);
}


The service is invoked by the following actionscript call

srv.send()

JSON doesn’t support Date objects out of the box, but it’s a nice way to exchange complex data such a Hash and Map between Rails and Flex.

Update: time.onrails.org. Add Notes to your time entries!

Updated time.onrails.org

The new functionality is

  • Add notes to your time entries. You can now add notes from the Dashboard or your project pages.
  • Improved CSV export.

Some functionality I am considering next:

  • fixing the rendering in Internet Explorer. I just saw this bug since I installed Parallels on my MacBook pro.
  • Blinksale integration, I started to write the UI to submit a time section to generate an invoice via Blinksale, but I am still waiting to get access to the api. Unfortunatly I didn’t make to the beta of the API. I even tried to convince Josh Williams from Firewheel Design, to let me in on it, but without success. Thanks Josh for the quick response anyhow!

Obie Fernandez – Ruby on Rails Podcast

Obie Fernandez of ThoughtWorks gives a peek into how Ruby is making inroads into the enterprise.

Obie Fernandez – Ruby on Rails Podcast

Obie Fernandez of ThoughtWorks gives a peek into how Ruby is making inroads into the enterprise.

remote_function :with


<%= select_tag “content_type”, options_for_select(content_type_options),
{ :onchange =>
remote_function(
:url => {:action => ’filter_by_content’},
:with => ‘Form.Element.serialize(this)’) } %>

The above code allows to submit via javascript the selected value of a combo box. The remote call is triggered via the onchange event handler of the select tag. Notice the parameters to the remote function call :url, as usual, but also the :with parameter. The :with option can be very useful if you need more control on what data needs to be sent to the server. In this case we use Form.Element.serialize that url encodes all the parameters found in a given div (doesn’t need to be a form). In this case the content_type=snippet is passed to the server.