RailsWayCon 2009 day 2

Veröffentlicht von Jens am 04. Juli 2009

Finally I found time to finish my writeup about the second day of railswaycon 2009.

RailsWayCon Session: Integrating Enterprise Java with JRuby and Rails

Michael Johann

Michael showed some examples how to integrate Java with Ruby. The reasons for integrating Java with Rails might be reruse of java code or a smooth transitition to Rails.

He showed some swing programming from the jruby console and he used a EJB enitity bean fasade with a rails controller to provide a restinterface.

The talks was in a bit slow in general. I think Johann an the croud was still a bit tired from the webinale party the day before. But the talk gaves a really great overview integrating java with ruby.



RailsWayCon Keynote: From Rails to Rack: Making Rails 3 a better Ruby Citizen

Yehuda Katz

In his Keynote Yehuda haves an an overview of Rails 3 which will be a merge with Merb.

In Rails 3 every part of rails will be a standardized Rack app. Rails with using Rack as a Core feature will be able to use and provides middleware in the rack standard. This will make testing much easier, because you can just mock every rack part of Rails.

This will make it much easier to replace parts of Rails with your own stuff. For example replace Active Record with Sequel or DataMapper and keep the Rails form magick work. Or replace prototype/script.aculo.us with jquery without loosing the rails ajax helpers.

Great Keynote!



RailsWayCon Session: Rails in Large

Neal Ford

Neal gaves an overview how thoughtworks build on of the biggest rails apps. It’s the vehicle trade plattform ove.com.
According to Neil ove has about 7million page views per week and they build the app with 11 pairs of developers, 8 buisness analysts and other staff.

He gaves a great overview how the development process at thoughtworks works and how the solve their problems.



RailsWayCon Session: Ruby/Rails in the Enterprise

Maik Schmidt

Maik explaind how to solve typical problems programmers will face when developing Rails applications in a common enterprise environment.
Like large amounts of date in xml files lets you run in performance problems with rexml (you can solve them with using libxml).
Or i18n will force you to monkey patch active record because the sales department want different looking validation error messages.

A really great talk.



RailsWayCon 2009 day 1 part 2

Veröffentlicht von Jens am 06. Juni 2009

RailsWayCon Keynote: Present and Future of Programming Languages Through a Ruby Lens

Ola Bini

Ola gives an awesome Keynote about his toughts on programming languages in general.
The talk was really great and he gives so much information in a short time that is hard to
cover everything in a blog entry. He made some assumtions which I will repeat here for you:

  • The jvm is great and will be there a long time. I totally agree to this. The jvm is a great pice of software engineering.
  • Don’t use the term “Scripting” language call it pragmatic languages. For Ola and probably a lot of people out there scripting language has a negative sound. I personaly don’t think so but he made a good point.
  • Natural Languages are not rational designed and not logical in a lot of cases. The Sapir Worph hypotesis (where bdd is based on) doesn’t matter for natural languages but it does in programming languages.
  • This points are important to Ola as language designer: communication, abstraction, expressiveness (remove everything whats not relevant to buisness logic), first class access (for example eval in ruby).
  • The language is more important than the tools. That’s a point I totally agree. Especially in the java world people talk all the time about tools and forget the essence what’s really important: Get the job done in a simple, kiss and dry way. A Simple soluten without any tool support is much better than a complex solution with great tool support.
  • For Ola in the future there will be more than less programming languages. So if you know just one programming language it might be a good idea to learn another one.



RailsWayCon Session: Ruby sittin on the Couch

Alexander Lang

Alex talk was about CouchDB. Apache CouchDB is a distributed, fault-tolerant and schema-free document-oriented database accessible via a RESTful HTTP/JSON API.

So, why Couch DB?
Alex says:

  • RESTful HTTP Interface
  • Store/read JSON documents
  • provides map reduce
  • It Scales on a single node by optimistic locking
  • muliple nodes (master/master replication)

The english was a bit hard to understand in some parts of the presentation. And I missed some comparison between CouchDB and a relational db model.



RailsWayCon Session: What is good UI?

Steven Bristol

Steven demonstrated 5 revisions of less accounting to get an impression how the user interface of the app changed and improved over the time.

Steven gave some nice tips for making a good ui:

  • You don’t get it right the first time
  • Whats your app? Do that not more.
  • Write more code so your users don’t have to do so much.
  • Ask for feedback
  • Use your own applications
  • If it’s hard to code a webpage the ui is bad



RailWayCon 2009

Veröffentlicht von Jens am 22. Mai 2009

The conference on Ruby, Rails and more. Auf nach Berlin:

Eintrittskarte RailsWayCon

HOWTO: Install a rails stack with ruby-enterprise and passenger on CentOS

Veröffentlicht von Jens am 22. Februar 2009

Preparations:
Install CentOS with Apache and Mysql.

1. Install ruby enterprise:

  1. wget http://rubyforge.org/frs/download.php/41040/ruby-enterprise-X.X.X-X.tar.gz
  2. tar xzvf ruby-enterprise-X.X.X-X.tar.gz
  3. ./ruby-enterprise-X.X.X-X/installer

2. Create some links:

  1. ln -fs /opt/ruby-enterprise-1.8.6-20080624 /opt/ruby-enterprise
  2. ln -fs /opt/ruby-enterprise/bin/gem /usr/bin/gem
  3. ln -fs /opt/ruby-enterprise/bin/irb /usr/bin/irb
  4. ln -fs /opt/ruby-enterprise/bin/rake /usr/bin/rake
  5. ln -fs /opt/ruby-enterprise/bin/rails /usr/bin/rails
  6. ln -fs /opt/ruby-enterprise/bin/ruby /usr/bin/ruby

3. gem install rails -v 2.X.X

Problems:
I’ve got problems with missing Mysql libraries. To fix this:

3.1 Install mysql-devel

  1. yum install mysql-devel

3.2 Install mysql-gem

  1. /opt/ruby-enterprise-1.8.6-20080624/bin/ruby /opt/ruby-enterprise-1.8.6-20080624/bin/gem install mysql — –with-mysql-include=/usr/include/mysql –with-mysql-lib=/usr/lib64/mysql

4. Passenger (mod_rails)

4.1 Install Passenger (mod_rails)

  1. gem install passenger

4.2 Passenger Apache Module

  1. passenger-install-apache2-module

5. ImageMagick

5.1 Install ImageMagick Libraries

  1. yum install ImageMagick-devel

5.2 Install rmagick via gems

  1. sudo gem install –no-rdoc –no-ri –no-update-sources rmagick -v 1.15.15

Problems:

Parameter –version doesn’t work.
Don’t use the parameter “–version”

Read more about this problem:
http://www.beanlogic.co.uk/2008/8/13/installing-a-specific-verison-of-rmagick

Missing msfonts

Installation of msfonts according to:
http://hi.baidu.com/rainchen/blog/item/089ef7364497de320a55a9a3.html

  1. wget http://www.osresources.com/files/centos-windows-fonts/msfonts.tbz
  2. mkdir /usr/share/fonts/default/TrueType
  3. tar xvjpf msfonts.tbz -C /usr/share/fonts/default/TrueType/

6. Config of apache and your rails app
For configuration of passenger follow the instructions there

Thats it!

Merb wird in Rails 3 gemergt! 1

Veröffentlicht von Jens am 24. Dezember 2008

Wow tolle Nachrichten zu Weihnachten. Merb wird in Rails 3 gemerged. Damit wird Rails modularer, schneller und bekommt eine stabilere API für Plugins. Frohe Weihnachten.

Weitere Infos:

http://weblog.rubyonrails.com/2008/12/23/merb-gets-merged-into-rails-3 

http://yehudakatz.com/2008/12/23/rails-and-merb-merge/

Ruby on Rails

Veröffentlicht von Jens am 16. Juli 2008

Since it first appeared in July 2004, Ruby on Rails has revolutionized the process of developing web applications. It has enabled web developers to become much faster and more efficient, al lowing for quicker application development a critical advantage in these days of web time.
(Orsini 2007, S.1)

 

Ruby on Rails ist ein in Ruby programmiertes Framework für die Entwicklung von Webapplikationen. Es wurde von David Heinemeier Hansson entwickelt und 2004 der Öffentlichkeit vorgestellt. Das Framework folgt dem Model-View-Controller Architekturmuster, bei dem das Softwaresystem in Datenhaltungsschicht (Model), Präsentationsschicht (View) und Programmsteuerung (Controller) aufgeteilt wird.

Ruby on Rails macht von der Möglichkeit der Metaprogrammierung gebrauch um Methoden zu definieren, die wie Erweiterungen der Ruby Syntax wirken. Es folgt dem Prinzip Don’t Repeat Yourself und stellt Konvention über Konfiguration.

Besonders hervorzuheben ist das Modul Active Record, das eine objektrelationale Abbildung der Datenbank nach dem von Martin Fowler, in Patterns of Enterprise Application Architecture, vorgestellten Active Record Designpattern bereitstellt. In Agile Web Development with Rails wird Ruby on Rails in allen Details beschrieben.

Aussagekräftige Html-Titel 1

Veröffentlicht von Jens am 02. Juli 2008

Jede Html-Datei muss einen Titel enthalten. Der im Html-Kopf notiert ist und für folgende Dinge verwendet wird:

  • Der Titel wird bei der Darstellung der Datei im Web-Browser in der Titelzeile des Browserfensters und in Karteireitern angezeigt.
  • Der Titel wird von Webbrowsern beim Speichern von Lesezeichen verwendet.
  • Der Titel wird im Verlauf der besuchten Seiten in Webbrowsern angezeigt.
  • Der Titel wird bei der Indizierung von Webseiten durch Suchmaschinen als wichtiges Merkmal verwendet.

Somit sollte der Titel möglichst exakt dem Inhalt der Seite entsprechen. Das wirkt sich positiv auf die Usability der Seitennavigation und beim Setzen von Lesezeichen im Webbrowser aus.

Ein Html-Titel muss im Html-Kopf einer Datei definiert werden. Der Html-Kopf sollte aus Gründen der Wartbarkeit nur an einer Stelle im Projekt notiert werden und alle Dateien sollten diesen zentral gehaltenen Html-Kopf inkludieren. Da Titel einer Html-Datei möglichst dem Inhalt der Seite entsprechen sollte, muss dieser im Idealfall für jede einzelne Seite angepasst werden. Den Html-Kopf in einzelne Seiten der Darstellungschicht zu kopieren würde jedoch dem DRY-Prinzip widersprechen.

Ein Ausweg besteht darin, im zentral gehaltenen Html-Kopf eine Funktion zu definieren, die das Titel-Element generiert und dessen Inhalte als Parameter von jeder Seite der Darstellungschicht übergeben werden. In der Darstellungschicht kann dieser Methodenaufruf gleichzeitig als Html-Überschrift verwendet werden die bei den meisten Seiten dem Html-Titel entspricht.

Patrick Crowley hat mit Headliner ein Rails Plugin geschrieben das genau das macht. Es ist wirklich einfach zu benutzen.

Nach der Installation über:

  1. script/plugin install http://the.railsi.st/svn/repo/plugins/headliner/

Muss eine zentrale Konfiguration des Plugins in der Layout Datei vorgenommen werden:

  1. <head>
  2. < %= title :site => "journizer.com", :separator => "-",
  3. :lowercase => true, :reverse => true %>
  4. </head>

In den einzelnen Views kann der Html-Titel jetzt mit:

  1. <h1>< %=t "My page title" %></h1>

gesetzt werden.

Suchmaschinenoptimierung für Rails Anwendungen

Veröffentlicht von Jens am 25. April 2008

Ich bin im Moment dabei mir Gedanken darüber zu machen wie man eine Ruby on Rails Anwendung für Suchmaschinen optimieren kann. Ich plane darüber eine kleine Serie von Artikeln zu schreiben.

Folgende Teile habe ich geplant:

Teil 1 von 4: Aussagekräftige HTML-Titel

Teil 2 von 4: Sinnvolle HTML-Meta Angaben

Teil 3 von 4: Menschenlesbare Urls

Teil 4 von 4: Sitemap.xml

Styleguide for Rails Projects 2

Veröffentlicht von Jens am 11. April 2008

Principles

DRY – Don’t Repeat yourself.
http://www.jensjaeger.com/2008/04/das-dry-prinzip/ (german)
http://en.wikipedia.org/wiki/DRY

KISS – Keep it Simple Stupid
http://www.jensjaeger.com/2008/04/das-kiss-prinzip/ (german)
http://en.wikipedia.org/wiki/KISS_principle

General

General Ruby Styleguide
http://rubygarden.org/ruby/page/show/RubyStyleGuide

General Rails Styleguide:
http://wiki.rubyonrails.org/rails/pages/CodingStandards

Language

Everything in the source code must be written in english. Including comments, variable names and function names.

Encoding

All files must be encoded with UTF-8.

Methods

Every method should have a meaningful name.
For a procedure name use a strong verb.
Example:

  1. Report.print

 

For a function name use a description of the return value
Example:

  1. Report.publishing_date

 

Avoid meaningless or wishy-washy verbs.
Descripe everything the method does.
Make names of routines as long as necessary.
The average length of methods should be from 15 to 20 characters.

Variables

Every variable should have a meaningful name.
The most consideration in naming is that the name fully and accurately descripe the entity the variable represents.
The average length of a variable should be from 8 to 15 characters.
Use shorter name only for iterators in really short scopes.
Example:

  1. reports.each do |r|
  2.   r.print
  3. end

 

The scope of a variable should be as short as possible.
Arrays should have a plural name.
Example:

  1. reports = Report.find(:all)

 

Everything else should have a singular name.
Example:

  1. report = Report.find_by_id(1)

Constants

Naming like variables.
There should be no numbers in the sourcecode. Every number should be a constant defined in environment.rb.
Example:

  1. PAG_PAGES = 10 #items per page for pagination

Comments

Comment as much as possible.
You shouldn’t comment WHAT your code does (this would be hurt the DRY-Principle), you should comment WHY your code does something.

Stay DRY

If you are doing something more than once, extract it into a method. This is especially the case when it comes to conditional queries. So instead of writing:

  1. @reports = Report.find(:all, :conditions => ["deleted = ", 1])

you should write a method:

  1. class Report < ActiveRecord::Base
  2.   def find_deleted
  3.     find(:all, :conditions => ["deleted = ", 1])
  4.   end
  5. end

Paranthesis

Use paranthesis with “standard” method calls and no paranthesis for helper-style hash arguments. Example:

  1. Report.find_by_id(1)
  2. #instead of
  3. Report.find_by_id 1

but

  1. ink_to "view", { :action =>; "view" }
  2. #instead of
  3. link_to("view", { :action => "view" })

Acknowledgments

Thanks to Florian Gilcher for the helpful comments.