So far, it\’s RoR

Ruby on Rails, PostgreSQL, SVN, etc….

Archive for July, 2007

Changing a revision property in Subversion

Posted by Chirag Patel on July 22, 2007

I’m using Subversion and needed to change a revision property (in my case, the log message) of a particular revision of the code. When I tried to do it with TortoiseSVN (Show log > Right click on a revision > Edit Log Message), I got the following error message:

DAV request failed; it's possible that the repository's pre-revprop-change hook either failed or is non-existent

Basically, Subversion doesn’t allow you to modify log messages because they are unversioned and will be lost permanently. They don’t want you screwing things up by accident! Therefore, you have to set up a hook script that the Subversion server will invoke when you try to change the log message in TortoiseSVN. In the case of log messages, you need to set up a pre-revprop-change script. There are other ‘hooks’ such as post-commit which allows you to run some custom stuff after you’ve made a commit. These hooks are located in the hooks subdirectory of the Subversion repository directory on your server. Inside that directory, there are a bunch of template scripts (e.g. pre-revprop-change.tmpl) that can be modified to be used for your particular repository. If you’re running the Subversion server on UNIX, setting up the pre-revprop-change script (so that log messages are allowed to be modified) can be done like this

  • Go to the hooks directory on your Subversion server (replace ~/svn/reponame with the directory of your repository)

cd ~/svn/reponame/hooks

  • Remove the extension

mv pre-revprop-change.tmpl pre-revprop-change

  • Make it executable (cannot do chmod +x!)

chmod 755 pre-revprop-change

Now try modifying the log message again.

Posted in Subversion | 5 Comments »

Slick Flash charts (Ziya + XML/SWF) for Rails for a great price

Posted by Chirag Patel on July 21, 2007

I recently installed a really nice set of charts and graphs called XML/SWF Charts using the Ziya plugin for Rails. The nice part is that it costs only $45 for your entire domain. This license fee will remove the link when you click on the chart (it currently goes to their website)

For the most part, the instructions in Ziya’s README were very good. I did run into a few snags, but they didn’t take me too long to figure out. Here’s a rundown. Hopefully this will make it even easier to implement Ziya and XML/SWF:

Under the “Steps” section of the the README:

1. If you get an error message when trying to install the Rails plugin on Windows, be sure to install the Window’s subversion client. This will install the command line svn client and add the subversion path to your environment variables. Be sure to open a new command prompt after installing the subversion client. This is the quickest way to get the latest version 0.12 of Ziya since they don’t make the latest code downloadable.

2. There’s an obvious typo in the following line

graph  = Ziya::Charts::Bar.new( license, title, chart_id )

I changed it to the following to get something working quickly:

graph  = Ziya::Charts::Line.new( nil, nil, "mychart" )

Here, "mychart" is the name of the YAML stylesheet which will be:

public/charts/default/mychart.yml

3. My biggest mistake: You can not instantiate the Ziya object in the controller corresponding to the chart’s view. It needs to be in a separate controller. Otherwise, an XML file (instead of a chart) will be returned when that controller is invoked.

In other words, if the following view code is in line_chart.rhtml file (note: here the ‘css_id’ is the id attribute for the <object> element that is rendered in the final HTML)

<%= ziya_chart( url_for( :controller => 'blee', :action => 'refresh_my_graph' ), :id => 'css_id', :bgcolor => "transparent", :width => 400, :height => 250 ) %>

Then you cannot put the following code in the line_chart controller

def line_chart
graph  = Ziya::Charts::Line.new( nil, nil, "mychart" )
graph.add( :axis_category_text, [ "Dog", "Cat", "Rat"] )
       graph.add( :series, "Series A", [10, -20, 30] )
       render :xml => graph.to_xml
end

The controller name needs to be different. They used refresh_my_graph as an example

4. The parameters passed into into the ziya_chart helper in the line_chart.rhtml file above apply to the canvas_bg property. These parameter apply to main canvas of the chart and cannot be specificed in the YAML file. The attributes for canvas_bg become part of the static html page.

The best way to specify attributes in the YAML stylesheet is to look at XML/SWF’s reference. It is very well documented and very understandble.

5. I was able to get their sample charting application working pretty quick. It’s the code for Ziya’s website. Download it by typing this at the command prompt (after you’ve done #1 above)

svn co svn://rubyforge.org/var/svn/liquidrail/samples/charting

After you download it, you will need to

a. Create a database called “ruby_dev” in your database server

b. Run db:migrate

Thanks a lot to the folks at maani.us for providing such a nice and rich set of graphs and charts for next to nothing. And also thanks to Fernand Galiana and Delynn Berry for such a nicely written plugin to the Rails community!

Posted in Ruby on Rails, Windows | Leave a Comment »

RoR IDEs for Windows

Posted by Chirag Patel on July 10, 2007

Updated on 12/11/07

Here’s a breakdown of Ruby on Rails IDEs for Windows. Please feel free to add to this by adding a comment to this blog entry. I currently switch between RoRED (writing and navigating code) and Netbeans (GUI debugging)

I broke it down in 2 types. Free vs. Commercial

Free

RoRED

RoRED is a low-frills alternative to Netbeans and Aptana. I’m using it exclusively at the moment because Netbeans is too clunky and I love the MVC tabs. It doesn’t have as many features, but is a nice quick and easy IDE. My favorite things about RoRED (in priority order):

  1. Very lightweight (only 7MB in RAM on my Vista tablet)
  2. Special tabs for Model-Views-Controller grouping! This is very nice because you can psychologically group code by functionality as opposed to folder. I use RoRED instead of Netbeans on many occasions just for this feature alone!!!
  3. How it generally uses tabs/panes insead of hierarchal trees (eg. methods within controllers, MVC tabs).
  4. Ability to load existing RoR projects without a “New Project” process or wizard. You can analyze someone else’s project or tutorial quickly.
  5. Global search (search across files) is pretty cool. Searching is quick and the search results windows goes transparent when you click on one of the search result rows.
  6. Ability to quickly switch between the controller and view of a particular method (which is probably available in most IDEs)

The things I don’t like are

  1. Can only load one RoR application at a time (takes too long to re-open all open files when switching projects)
  2. Autocomplete is very slow (and not that impressive). Very annoying when you type an open parentheses and it waits for autocomplete

Netbeans

Since I have 4GB RAM on my Lenovo tablet, I can take advantage of all its rich features. When I launched Netbeans 6.0 M10 with three RoR projects loaded, the Windows process (java.exe) ended up being a whopping 150MB (as opposed to 7MB with RoRED)! Not for the faint hearted.

I’ve seen 2 blog entries claiming that it’s now better than Aptana. I put the dates because obviously opinions change fast.

  1. July 02, 2007 on Technology for Humans
  2. June 11th, 2007 on Eribium

What I like about Netbeans

  1. GUI debugger!
    • Shut down your existing web server!
    • Run -> Attach Debugger
    • Run -> Debug Main Project
    • Veify that debugger is running (Window -> Output -> Output)
    • Warning: sometimes the breakpoint won’t hit
  2. Integration with Subversion, so I can do a quick diff in the editor
  3. Ability to easily create project from an existing Ruby On Rails application
  4. Local history and the ability to label and delete each entry in the local history (Versioning -> Local History)

What I don’t like about Netbeans

  1. Launches very slowly! And is a memory hog!
  2. Seems to index every Rails project every time you launch Netbeans, which is very slow
  3. Autocomplete can be slow (2 to 5 seconds)
  4. Creates a directory called “nbproject” in your Rails root directory. I have Subversion ignore it.

Aptana

Used to be RadRails, but recently bought by Aptana. It was a little clunky and flaky when I used it as Radrails a few months ago. See Aptana vs Netbeans articles above.

FreeRIDE

Supposed to include some re-factoring, but haven’t tried it. Seems pretty primitive.

Ride-ME (Rails IE – Minus Eclipse)

A few months ago, it was buggy and not very impressive

Commercial

Arachno $50-$100

Released a version in July 2007. Haven’t tried it but screenshots look good. Hopefully it would be lighterweight than Netbeans

Ruby in Steel $200 + price of Visual Studio

Runs on top of Visual Studio, which very nice but obviously a resource hog

Komodo $150

Nothing stood out about it when I tried the trial version

IntelliJ IDEA $500

One of the best IDEs ever made, but I hear it’s so big and clunky nowadays, that it’s almost impossible to use. See ruby-rails-ide-comparison-idea-netbeans-radrails

Posted in Ruby on Rails, Windows | 1 Comment »