Ruby implementation + GUIs

Posted by Krzysztof Rączkiewicz Tue, 03 Apr 2007 21:46:00 GMT

I’ve just found post with news – Microsoft is “very interested” in the Ruby. Till now we’ve got abandoned project (last update – 2004) Ruby-.NET from http://www.saltypickle.com/rubydotnet and Ruby.NET from http://www.plas.fit.qut.edu.au/Ruby.NET/

We’ve got severals implementations of Ruby in different languages. For me most important is JRuby. Especially that two weeks ago the 1.0 release of rails-integration jar shows up. More information about it you’ll find of course here.

I would like also point you to nice comparision/list of Ruby GUI Toolkit projects.

Tags , , , , , ,  | no comments

Prototype your Rails application

Posted by Krzysztof Rączkiewicz Tue, 20 Mar 2007 12:26:00 GMT

Today I want to show you some piece of software that will help you quickly prototype your Rails application. We all know the scaffold mechanism. Without it there wouldn’t be famous Weblog in 15 minutes screencast. It’s really nice for beginning or if you what to quickly show someone (or to yourself) the idea of your application. But scaffold generate not very beautiful code. E.g.:
<% for column in User.content_columns %>
    <th><%= column.human_name %></th>
<% end %>
I’ll present you four tools that may look interesting for you: But first I’ll give you an idea how my sample app look. I will use one model (with one table associated of course). This is how migration file looks like:
create_table :users do |t|
  t.column :first_name, :string
  t.column :last_name, :string
  t.column :address, :text
end

Custom scaffold

You can obtain it from here and you install it just by unpacking it to YOUR_APP/vendor/plugins/ . After that you could check that you’ve got your new generator:
YOUR_APP$ ./script/generate
..
Installed Generators
  Plugins: custom_scaffold
..
Now all you need to do is to generate custom scaffold for your model (you don’t need to specify controller name, but it’s possible)
YOUR_APP$ ./script/generate custom_scaffold User admin
It’s generating much more prettier code,
<% for user in @users %>
  <tr>
    <td><%= user.first_name %></td>
    <td><%= user.last_name %></td>
    <td><%= user.address %></td>
    <td><%= link_to 'Show', :action => 'show', :id => user %></td>
    <td><%= link_to 'Edit', :action => 'edit', :id => user %></td>
    <td><%= link_to 'Delete', :action => 'destroy', :id => user %></td>
  </tr>
<% end %>
but it also have some problems. It generate code in YOUR_APP/app/views/admin/_form.rhtml with non existing method
<%= error_for 'user', 'first_name' %>
So you need to delete it or add this method definition to application helper, something like1 this

You can customize templates in YOUR_APP/vendor/plugins/custom_scaffold/generators/custom_scaffold/templates

MasterView

Authors call it template engine and you could get it from here. It is distributed as gem or plugin and installation is described on the main page. You can also watch screencast presenting MasterView power, so I will not focus on it.

Streamlined

This one is really nice and quite powerful. With help of this plugin you can generate nice, powerful including JavaScript interface for you ActiveRecord models. At the beginning, it was used mainly for administrative purpose, but there’s no contraindication to use it for general stuff.

You can watch nice screencast available at the framework homepage

Although it’s looks great, it also have few problems. First of all – lack of documentation and some times those doc’s are out of date. Also as you see it’s in early development so sometimes you could find a bug.

Ok. First create rails app, install plugin (version 0.0.7.1) configure your database then create model and controller:
dev$ rails streaml
dev$ cd streaml
dev$ ./script/plugin install http://svn.streamlinedframework.org/edge/streamlined
[CONFIGURE_DB]
streaml$ ./script/generate model User
streaml$ ./script/generate controller users
It would be available2 to specify model used by streamline, nevertheless pay attention to plural noun users right now. First of all add some code to application helper
module ApplicationHelper
  include StreamlinedHelper
end
Add code to your controller
class UsersController < ApplicationController
  layout 'streamlined'
  acts_as_streamlined
end
Now you could test your app. If you would like to use Ajax (editing, view etc.) you can meet problem in prototype library. You could find solution here There’s also generator available. You need to install older gem (e.g. streamlined_generator-0.0.6.gem from Download Streamlined section). After that you could generate “scaffold”
streaml$ ./script/generate streamlined user
and you’re able to make modifications of header, menu and layout generally in the stream/app/views/streamlined At the end I will show you quick UI configuration from the first example (version 0.0.7.1). Create file app/streamlined/user_ui.rb (if you need, create directory app/streamlined). Fill that file with:
module UserAdditions
end
class UserUI < Streamlined::UI
  user_columns :exclude => [:address]
end 
Refresh your view, and look at the difference. More examples here: Declarative View Options

Streamlined Edit in JavaScript window - Streamlined

AjaxScaffold

Last but not least Ajax Scaffold Generator. It is available as generator or dynamic plugin. I think all of you knows that soft and if you’ve never heard about it, there’s a bunch of good tutorial for newbies.

AjaxScaffold Edit - AjaxScaffold

1 Not exactly like this. You could see only an idea.

2 It would be available in 0.1.0 version

Tags , , , , , ,  | no comments

Textmate for Linux

Posted by Krzysztof Rączkiewicz Thu, 08 Feb 2007 00:32:00 GMT

Finally I did it. I’ve changed my blog engine to typo, and I’ve changed my language to English. Because of that please give me some feedback, when I make some (or lots of) grammar mistakes.

For the first, inauguration post I’ll describe my search for nice “editor” for rails development. Everybody knows that most popular, and beautiful is Textmate ;p. Editor that became standard, and prototype that everyone want to duplicate. I know that “de gustibus non disputatum est” so first I present some other products and then my final choice (for now :) )

At the begging I’ve used RadRails. It was quite nice, but first I had some problems running it on amd64 (you need to pay attention to java version – 32 bit). Now I have ubuntu 32bit, so then some new problems showed up. First of all I needed some other plugins, like for html, css and so on. So I started to use EasyEclipse LAMP which has everything that I need. But finally I thought it’s to big for me. I’ve used snippets from here and theme form there

I’ve also tried to use jEdit, prepared by colleagues from Polish Ruby on Rails forum. I’ve got some errors during usage, and I can say that it isn’t most beautiful editor I saw. Yes, yes.. I know that it’s only tool, and you should write software not admire themes.. but like DHH said (and not only him) motivation is really important during development process. Motivation comes from happiness, and I feel really happy writing my code in beautiful environment :)

I should come to the crux of the matter, so I want to present you how to make gedit to be your mate, to look and work like Textmate.

Step 1

Install gedit and gedit-plugins.

Step 2

Go to Edit->Preferences->Plugins Make “Snippets” plugin available. Get ruby and erb snippets from here and copy them to ~/.gnome2/gedit/snippets

You can check them in Edit->Preferences->Plugins->Snippets & Configurate plugin

Step 3

Get more plugins..
  1. Eddt for nice directory browsing plugin
  2. Class browser for class browser
  3. Snap Open for opening files based on regexp. At the same site there is set of files with textmate colors and font settings, but I set them manually.

Optionally you can install others

You will get something like:

gedit like textmate

gedit like textmate

that’s all for now

Tags , , , , , , , ,  | 4 comments