www.question-defense.com | Engage: Visit :: Login :: Register
Translate to English Übersetzen Sie zum Deutsch/German Переведите к русскому/Russian Μεταφράστε στα ελληνικά/Greek Vertaal aan het Nederlands/Dutch ترجمة الى العربية/Arabic 中文翻译/Chinese Traditional 中文翻译/Chinese Simplified 한국어에게 번역하십시오/Korean 日本語に翻訳しなさい /Japanese Traduza ao Português/Portuguese Traduca ad Italiano/Italian Traduisez au Français/French Traduzca al Español/Spanish

Archive for August 10th, 2008

0

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

DeliciousStumbleUponDiggTwitterMixxTechnoratiFacebookNews VineLinkedInYahoo! Bookmarks
Tags: , , , , , , , , , , , ,

Comments 2 Comments »

0

When writing Rake tasks, to get access to all classes (such as the User model in this example) in your app’s environment, you need to depend on the :environment task shown as follows:

  task :post_user => :environment  do
    end_time = Time.new
    start_time = end_time - 60 #subtract 60 seconds
    until start_time > end_time
      start_time = start_time + 15 #increment 15 seconds
      puts "Posting #{start_time}"
      uesr = User.new(:user_id => 817, :timestamp => start_time)
      user.save
    end
  end
DeliciousStumbleUponDiggTwitterMixxTechnoratiFacebookNews VineLinkedInYahoo! Bookmarks
Tags: , , , , , ,

Comments No Comments »

0

Using this as a guide JLHPBv2: Using Helpers in Models in Rails, you can make a single Module that can be accessed from models, views, and controllers. The helpers automatically created in app/helpers/*_helpers.rb   might also be available anywhere as long as you include them.

I decided to make the methods in the helper class-scoped (using self below) so that the origin of the helper method is explicitly obvious in the call (eg. to_s below)

app/lib/utility_helper.rb
module UtilityHelper
  def self.camelcase_to_spaced(word)
    word.gsub(/([A-Z])/, " \1").strip
  end
end

app/models/event.rb
class Event < ActiveRecord::Base
  include UtilityHelper

  def to_s
    UtilityHelper.camelcase_to_spaced("This an Event object")
  end
end

app/helpers/events_helper.rb
module EventsHelper
  include UtilityHelper
end

app/controllers/event_controller.rb
class EventController < ApplicationController
  include UtilityHelper
end


app/views/events/index.html.erb
<%=UtilityHelper.camelcase_to_spaced(event[:event_type])%&rt;

DeliciousStumbleUponDiggTwitterMixxTechnoratiFacebookNews VineLinkedInYahoo! Bookmarks
Tags: , , , , , , , , , ,

Comments 3 Comments »

0

Layout basics

Here’s Duane Johnson’s concise explanation of how layouts generally work in Rails. To summarize this blog article, layouts occur at 2 levels (applciation-wide or controller-wide) by default:

  • The entire Rails application (all views of all controllers) will use this layout:

views/layouts/application.rhtml

  • All views within a single controller will use this layout. For example, the layout for weclome_controller.rb will use this layout. Notice, the ‘_controller’ is left off for the layout:

views/layouts/welcome.rhtml

  • Use this code if you want to use a different layout than one of the two default layouts described above. This code will go in the action (index, in this case) corresponding to the view (index.rhtml)

def index

render :layout => ‘alternative_layout’
end

When using Rails layouts, the final page is rendered by using <%= yield %> in the layout. With <%= yield %>, the view is placed inside the layout during runtime. For example, the application-wide layout application.rhtml could contain the following:

<title>Layout Example</title>
  </head>
  <body>
    <%= yield %>
  </body>
</html>

The view (e.g. index.rhtml) for weclome_controller.rb could look something like this:

<b> Hello World </b>

This would render the following final .html page when you enter http://localhost:3000/welcome in your browser:

<title>Layout Example</title>
  </head>
  <body>
    <b> Hello World </b>
</body>
</html

Nested Layouts

To create nested layouts (master layout > sublayout > view), I found the following 2 options
<!–[if !supportLists]–>

  1. Using partials and qualifying methods as described in Matt McCray’s blog. Matt’s got an example Rails app that you can download and try. Also here’s a more visual layout of the code that he explains:
    • Matt McCray’s Nested Layouts
  2. Using the nested-layout plugin

I prefer the first method because its pretty simple and uses inherit Rails methods instead of a plugin that could end up being more maintenance and possibly inflexible later on.

Last, here’s a really good write-up for web designers transitioning to Rails (includes basics about MVC, rhtml, ERB, etc)

DeliciousStumbleUponDiggTwitterMixxTechnoratiFacebookNews VineLinkedInYahoo! Bookmarks
Tags: , , , , , , , ,

Comments 4 Comments »

0

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.

DeliciousStumbleUponDiggTwitterMixxTechnoratiFacebookNews VineLinkedInYahoo! Bookmarks
Tags: , , , , , , , ,

Comments 4 Comments »