http://www.railsonwave.com/railsonwave/
Last checked less than a minute ago.
11 people have subscribed to this feed.
post frequency (last month)
PostRank™
From RailsOnWave Ruby on Rails web 2.0 Ajax - Home, 17 days ago,
0 comments
Today I come up to Scrubyt, an excellent piece of code developed by Peter Szinek, Glenn Gillen and a bunch of other collaborators. What this software do is essentially fetch and operate on XML/HTML pages, here’s an example taken from the official website:
require 'rubygems'
require 'scrubyt'
ebay_data = Scrubyt::Extractor.define do
fetch 'http://www.ebay.com/'
fill_textfield 'satitle', 'ipod'
submit
record "//table[@class='nol']" do
name "//td[@class='details']/div/a"
end
end
puts ebay_data.to_xml
In this ten lines of code (including the two ‘require’ on top of the page) we fetch ‘ebay.com’ website, then we fill a textfield with the id ‘satitle’ with the text ‘ipod’ and we press the submit button. Next we create a container (named ‘record’) for each table with class ‘nol’ of the returning page (the page containing the results from our ‘ipod’ search) and we fill this container with a ‘name’ variable containing the text within an ‘A’ element incapsulated inside a td with class ‘details’.
If we print the result as xml (as we do in the last line) this will be the output (truncated):
<root>
<record>
<name>USB 2.0 Sync Data Cable for iPhone 3G iPod Mini NanoPOWER SELLER-30 DAYS MONEY BACK GUARANTEE-FAST SHIPPING$1.99Free shipping22d&#160;5h&#160;50m</name>
</record>
<record>
<name>EnlargePIONEER 5.8" GPS NEW AVIC-F90BT DVD MP3 IPOD AVICF90BT!!! HAS THE NEW 2.0 UPDATE INSTALLED !!!!! 2.0 UPDATE$637.00Free shipping9d&#160;5h&#160;35m</name>
</record>
<record>
...
In conclusion, this is a very nice and handy toy that can help us during deployment and test.
From RailsOnWave Ruby on Rails web 2.0 Ajax - Home, 1 month ago,
0 comments
If we consider the business world, since the Blackberry was released in 2002, it broadened the use of IT in the business world. Receiving e-mail on your smartphone and being able to be updated in real-time was a useful tool for everyone.

The iPhone changed the whole game of the smartphone. Not only is it an interesting little device that allows you to be updated with your e-mail, organize your appointments, manage what you need to do but so many more applications are being developed that have reached the top of the top 25 list of apps to have. Like the new Google voice search application that enables you to search a website using your voice, but I have tried it and maybe it didn’t like my voice…
iPhone applications have created another dimension in the development of web applications, not only to develop web 2.0 applications in Ruby on Rails but for our applications to be successful and competing within the current market, we need to develop iPhone web applications that are synchronized with our web applications. A simple to-do list application is much more useful if you can view it on your iPhone and manage it from there too.
But then I ask myself…
is it better to develop iPhone web applications or native applications?
Some advantages of web applications :
If anyone has any comments I would appreciate it.
Thanks
From RailsOnWave Ruby on Rails web 2.0 Ajax - Home, 2 months ago,
0 comments
While installing Globalize I stumbled upon the plug in’s table structure. If we look at the ‘tr_key’ field inside the table ‘globalize_translations’ we may notice that this field type is ‘VARCHAR (255)’ (obviously only under mysql but I think this is the database chosen by the majority of rails developers).
Hey, but isn’t this column the one holding the strings to be translated?
The answer is (ASAIK) yes, in fact if we look inside file ‘view_translation.rb’ (inside the plug in’s models’ folder) we spot this piece of code:
def self.pick(key, language, idx, namespace = nil)
conditions = 'tr_key = ? AND language_id = ? AND pluralization_index = ?'
namespace_condition = namespace ? ' AND namespace = ?' : ' AND namespace IS NULL'
conditions << namespace_condition
find(:first, :conditions => [conditions,*[key, language.id, idx, namespace].compact])
end
Wow, the ‘tr_key’ is used also to store and (as shown here) retrieve translations from the db; but what happens if the string I’m trying to translate exceed the 255 chars limit?. Simple, the string get saved on the database truncated at its 255th character, then when the plug in try to search for this string obviously it didn’t find anything (‘cause it’s looking for the whole string, not its first 255 chars); the result? A string longer than 255 chars never get translated plus it creates a duplicate row each time is called its ‘t’ method.
The fix I coded is pretty easy:
def self.pick(key, language, idx, namespace = nil)
conditions = 'tr_key = ? AND language_id = ? AND pluralization_index = ?'
namespace_condition = namespace ? ' AND namespace = ?' : ' AND namespace IS NULL'
conditions << namespace_condition
find(:first, :conditions => [conditions,*[key[0...256], language.id, idx, namespace].compact])
end
In this way you just need to be aware of long string with the first 255 chars in common; but this is quite rare, so you can easily ignore it.
Sandro
From RailsOnWave Ruby on Rails web 2.0 Ajax - Home, 2 months ago,
0 comments
With the release of Googles browser Chrome, as Web Developers I think we could take a few pointers that I am sure we all know about but sometimes we need to be reminded.
Google wanted to introduce a browser that had multiprocess architecture. Other browsers, if one of the tabs crash the whole browser crashes. In our web applications we need to take advantage of new technology like Rails 2.2 and develop applications that are innovative making use of technology to develop new concepts and ways of solving a problem.
We need to identify critical factors of the applications and understand how we will solve them, using existing plugins, gems or developing our own solution to solve the problem.
Keeping it simple and use only the technology that is needed. Redundant use of gems, plugins or scripts will slow down or application let alone the time spent to implement them.
As google puts it “Placing blame were blame belongs”.
Why did a web application fail? I think there are many factors that could lead to a project failing, one of the important factors is that not enough planning and brainstorming has been done before starting a project. We jump right into the code without understanding the concept and setting or goals on what we want to achieve.
Not having the technology available at the time. For example, with Rails, what is introduced in Rails 2.2 did not exist in previous versions of Rails.
Eliminate factors of a project that didn’t work before and develop a strategy on what can be done to improve them and how.
Testing is crucial as in the long run, it will save time and money. Doing continuous testing on a project will enable you to see come across errors sooner, being able to correct them immediately, saving time and cost from the start of development.
Develop a test analysis, identifying various testing paths that we need to do to test the application and be obedient to implement these test strategies.
Use useful tools at our disposal. Google used V8 or we could use WebKit. These tools help us develop faster and discover errors quicker. So much time is spent on testing, with the use of useful tools, we can develop applications faster, leaving more time for perfecting.
References for this article was taken from Google chrome
From RailsOnWave Ruby on Rails web 2.0 Ajax - Home, 2 months ago,
0 comments
We come up with this solution after a couple of failing attempt to find a way to emulate a redirect_to method without actually create a 302 HTTP message which need to be sent to the user and then back to the application.
By using this internal_redirect_to function you will be able to get the same results as a normal redirect_to without send anything to the user, only keep in mind to explicit invoke the return after this function.
def internal_redirect_to (options={})
params.merge!(options)
(c = ActionController.const_get(Inflector.classify("#{params[:controller]}_controller")).new).process(request,response)
c.instance_variables.each{|v| self.instance_variable_set(v,c.instance_variable_get(v))}
end
Note: this function must be placed inside the calling controller.
Then you can simply invoke this function by typing:
MasterController < ApplicationController
def index
internal_redirect_to :controller=>'another', :action=>'an_action'
return
end
end
Sandro
From RailsOnWave Ruby on Rails web 2.0 Ajax - Home, 2 months ago,
0 comments
A useful CruiseControl.rb tasks that adds some extra checks to your application.
From RailsOnWave Ruby on Rails web 2.0 Ajax - Home, 2 months ago,
0 comments
Us at WhoDoes are always trying to improve our project management system to make it more user-friendly for our customers.
We have added a few new functionalities to WhoDoes:
1) you are now able to assign tasks to a document in the repository section 2) The task edit has a new layout that enables you to add documents, and send a notification email only to those you have selected in the tick box.
Please try out these new functionalities at WhoDoes 2.0
We would like to have your feedback on this new task edit layout, please e-mail us at feedback@whodo.es or click on the link on the task edit page.
From RailsOnWave Ruby on Rails web 2.0 Ajax - Home, 2 months ago,
0 comments
In the past few days I’ve come across a problem that is usually solved using a multi-table inheritance (also called Class Table Inheritance) approach, for those of you who don’t still know what ‘multi-table inheritance’ means here’s a small quote from Martin Fowler
[Class Table Inheritance] Represents an inheritance hierarchy of classes with one table for each class.
This pattern lead to a data aggregation problem; in fact you’ll need to mix data from two tables (one from the parent class and one containing the data of the current object). ActiveRecord actually does not offer a ‘out-of-the-box’ solution for this problem and the best way we can do is try to emulate this pattern.
On the web many posts have been written about this problem, each of them trying to figure out a solution that achieves the goal while keeping all the ActiveRecord features and maximizing elegance:
I’ve tried to figure out a possible ActiveRecord-friendly implementation for the common PartyRole architecture. In this schema you have a table called party which holds all the information about the user (name,e-mail, ...), a table called roles which contains all the possible roles a user could have (customer, seller, administrator, ...), a table that joins the two (called PartyRole) linking a user with its roles and a table with detailed data for each role (eg: ‘customer shipping address’ only for the customer role).
When you retrieve a PartyRole instance you need to mix the data of the user related to this partyrole with the information stored in the table named as the role this instance is using (eg: ‘Sandro as a Customer’ partyrole instance needed to retrieve data both from parties and customers tables).
As I’m writing this article I’ve only managed to flat the relationship between a PartyRole and its ‘role-dependent’ data; to do this I dynamically extend the PartyRole model creating (via STI) a dedicated PartyRole class for each of the roles stated in the roles table (eg: CustomerPartyRole, SellerPartyRole, ... ). In each of these classes then I create a ‘has_one :extra’ association that point to the table that holds the data related to this particular role:
Role.all.each do |r|
Object.const_set("#{r.title}#{PartyRole}".to_sym,Class.new(PartyRole))
Object.const_get("#{r.title}#{PartyRole}").class_eval do
has_one :extra, :class_name=>"#{r.title}", :foreign_key=>'party_role_id'
end
end
By this way you can retrieve the information related to a PartyRole simply invoking:
sandro = PartyRole.find(:include=>[:party],:conditions=>{:role=>Role.find_by_title('Customer').id, :party=>{:name=>'Sandro'}})
sandro.extra
# I'll get the information collected into the 'customers' table related to 'sandro'
sandro.party
# I'll get the information about 'sandro' stored into the parties table
The next step to achieve is to find a way to dynamically merge extra and party into the sandro instance, I’ve tried using Delegators but this does address the problems you face when trying to execute a query like this one:
CustomerRole.find(:all, :conditions=>{:'an attribute from the customers table'=>xxx })
So, if you have some ideas or suggestions, please share :)
Sandro
From RailsOnWave Ruby on Rails web 2.0 Ajax - Home, 3 months ago,
0 comments
I am sure you have read that a Visual Studio IDE for Ruby and Rails has been released, this probably will help those who are new to Ruby and we might even have some new comers to the Ruby on Rails community which is always welcome.
Even though this would be an advantage for those who are use to code completion, code indenting, bracket highlighting and matching and that what Visual Studio offers, to me this takes the fun out of Ruby on Rails.
I was introduced to Ruby on Rails last year April after being a Visual Studio user since it was launched, I must admit that at first I had to get use to the fact of programming without the code completer, but after a few weeks I was hooked, I loved the command line and programming dynamics of Ruby, with Ruby you are in control of your code, as my colleague described it, ruby is “the kind of language that you can talk to”.

I feel with Code completer you become lazy and dependent on the IDE, in programming there is always more than one way of doing something and Ruby allows us to do just that, exploring our horizons.
Therefore I will not be uninstalling my Textmate any time soon…
If you have not yet read about it, click here
From RailsOnWave Ruby on Rails web 2.0 Ajax - Home, 3 months ago,
0 comments
Firstly in Rails we need to call a method to refresh the page in the iframe, for example:
I have created a partial with the following:
<iframe id="myframe" src="<%= url_for :action => :file_upload" class="myiframe" scrolling=no style="border:0px;" >
</iframe>
This calls the method in the controller called file_upload and updates the iframe with the contents of the file file_update.rhtml
Within the method I have included a variable to set the height of the iframe depending on the number of documents that are in the list.
def file_upload
@iframe_height = @documents.count
@iframe_height = (@iframe_height * 28)+50;
end
When we load the iframe the following script is run in the body onload function and we pass the height parameter to it:
<body onload="iframeSize('<%=@iframe_height%>');">
We call the script to set the size of the iframe
<script type="text/javascript">
function iframeSize(size)
{
var height = size+'px';
var iframeElement = parent.document.getElementById('myframe');
iframeElement.style.height = height;
}
</script>
Using the Attachment_Fu plugin, we create the form to upload the files:
<% form_for :document, :url => {:action=>'save_file'}, :html=>{:multipart => true} do |f| %>
<div class="upload_document_box">
<label for="name"><%= "Title".t %>:</label><br>
<%= f.text_field :title, :size=>25, :value=>''%><br>
<label for="name"><%= "Attachment".t %>:</label><br>
<input type="file" style="width: 385px;" size="44" name="document[uploaded_data]" id="document_uploaded_data" value=''/>
<input type="submit" value="upload" name="commit" onclick="check();"/>
</div>
<% end %>
On the onclick of the submit button, we call the check() function in the script, this checks if a title of the document was inserted and that a document was uploaded. On our parent page we have a div with an id called “alertbanner”, this is where we will display the errors:
function check()
{
var title = document.getElementById('document_title');
var doc = document.getElementById('document_uploaded_data');
if (title.value == '')
{
parent.$('alertbanner').insert({ top: "<p> Please insert a document title </p>"});
}else
{
if (doc.value == '')
{
parent.$('alertbanner').insert({ top: "<p> Please select a document to upload </p>"});
}
}
The last step is to upload the file to the Database in the save_file method in the controller:
def save_file
@document = UploadedFile.new(params[:document])
if @document.save!
@error = 'Document was successfully uploaded'.t
@task = @selected_task
redirect_to :action=>'file_upload', :project_id => @selected_project.id, :id=>@selected_task.id, :flag=> false
end
end
With a successful upload of the file, the iframe will be refreshed with the new document in the list and assign a new height to the iframe
Some have us might have used the plugin responds_to_parent to update a list outside of the iframe, it is a very useful plugin although I have tried a different method and I would appreciate any comments or suggestions that you might have.
From RailsOnWave Ruby on Rails web 2.0 Ajax - Home, 3 months ago,
0 comments
We have created an audio version of David Heinemeier Hansson’s keynote for you to listen to, as well as on your iPhone.
David Heinemeier Hansson’s Keynote
Enjoy!
Annalisa
From RailsOnWave Ruby on Rails web 2.0 Ajax - Home, 3 months ago,
0 comments
We were fortunate to be present at the RailsConf Europe 2008, it took place in Berlin from 02 – 04 September.
DHH talks about Living with legacy Software, we have placed this Keynote on vimeo for you to watch.
Please click on the image below.
Enjoy!
Annalisa
From RailsOnWave Ruby on Rails web 2.0 Ajax - Home, 4 months ago,
0 comments
There exists two main formats to include semantic information inside a web page: MicroFormats and RDF. RDF is the protocol used by DBPedia, a real semantic encyclopedia that looks up for each term inserted a list of possible attributes (Click here for an example) in RDF format.
With active_rdf it is possible to interrogate a RDF page using SPARQL, a powerful query language , to only retrieve the information that we are interested in, this information can then be formatted inside the web page using the microformats.
To show a PoC (Proof-Of-Concept) of this technique Rob Lee has shown, in the course of the session, a script that:Applying a variation of the same techniques of Rob was to be able to create a platform that aggregates news looking at famous singers using the recording studios as a grouping factor to which they belong to.
From RailsOnWave Ruby on Rails web 2.0 Ajax - Home, 4 months ago,
0 comments
With slice we mean an application implemented inside a much bigger Rails application; lets take for example an institutional website, where it is necessary to include a blog; using an approach to Slices it is possible to integrate a Rails blog already available inside of which has already been developed up to now using a twin structure to that father application inserted in the sub folder apps/slices/blog.
To benefit from this approach it is necessary to modify the priority of access of the Rails classes and to add to the framework new load paths.
From RailsOnWave Ruby on Rails web 2.0 Ajax - Home, 4 months ago,
0 comments
The RailsConf Europe 2008 opens the knocks at Berlino, on a beautiful sunny day. In these days we look at opening a window about the conference, to show you the most interesting aspects that will be spoken about the future of Rails in Europe and in the world. To share with you the contents of the speeches, the articles are almost posted at real-time :)