Showing posts with label Rails. Show all posts
Showing posts with label Rails. Show all posts

Tuesday, April 3, 2012

How to replace WEBrick with Thin for Windows development

WEBrick still seems awful slow on Windows. Last time I played with Rails, Mongrel was the goto replacement for WEBrick. Alas, Mongrel's no longer supported. So then I learned Thin is the new Mongrel. Here's how to get it working on Windows:

First, you might have to do this to install thin on Windows:
gem install eventmachine --pre
gem install thin


thanks to frogz
Then add the line gem 'thin' to your Gemfile to make Thin the default server when you run rails s, et voila:
=> Booting Thin 
=> Rails 3.2.1 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
>> Thin web server (v1.3.1 codename Triple Espresso)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:3000, CTRL+C to stop

Monday, April 2, 2012

Rails: How to kill WEBrick 1.3.1 on Windows 7

This worked for me, using RailsInstaller on Windows 7 - launch the WEBrick process into a separate command window by using the start command:

C:\Sites\myapp>start "rails" rails s


This will open a new command window entitled "rails - rails s", running the WEBrick process, leaving the original command window available for use. 

When you're ready to kill WEBrick, just close the "rails" command window. Brutal, but effective. 

Friday, August 22, 2008

Railsconf '08 in 36 minutes

Thanks to Gregg Pollack of Rails Envy for posting Railsconf in 36 minutes for those of us who couldn't attend Railsconf '08 this year.

Sunday, August 17, 2008

Searching Ruby on Rails Docs just got a lot easier

Ruby on Rails is a big framework, with hundreds (thousands?) of methods and classes. Thanks to the clever folk at Nodeta, their new documentation app APIdock provides an easy-to-use search/browse interface to the whole of Rails documentation. To quote the site:


APIdock is a web app that provides a rich and usable interface for searching, perusing and improving the documentation of projects that are included in the app.


The site also provides documentation for Ruby and RSpec. Two really interesting features of the site are the versions bar graph and dynamic keyword search.



The versions bar graph along the top of each documentation page lets you "go back in time" to past versions of the documentation, by clicking on the version number. The green and red tabs indicate when and by how much the documentation changed for that version, which is handy when you're trying to figure out just when and in what way a particular method was changed or deprecated:





The dynamic keyword search displays a "find as you type" drop-down list from which you can select the relevant documentation page. A little pie graph icon, divided into five wedges, indicates by the number of filled-in wedges how much information is available for each item:




So for example there's a lot of information about the form_for helper, but very little about the apply_form_for_options! helper. If you get as lost in Rails as I do, or you're just wondering what is the difference between form_remote_for and remote_form_for (hint: the former is an alias for the latter).


Try it!

Saturday, August 2, 2008

Ruby on Rails 2.1.x Tutorial

Found a "to the point" tutorial over on Tutorialspoint.com that covers just enough Ruby on Rails 2.1.x to get (re)started.

Monday, April 14, 2008

Vote for mod_rails!

Hey, Dreamhost - when are we going to get mod_rails on our shared server accounts? Fellow Dreamhosters, if you've been waiting for an easier way to deploy and run small Rails apps, then vote for the mod_rails suggestion!

Monday, October 1, 2007

Getting the Aptana Help Server working on Windows Vista

Overcame a minor irritation - I kept getting an HTTP 500 internal server error from Aptana's built-in help documentation server after installing Aptana on my Windows Vista system. After some fiddling around with the Help Server's host name and port, I found the sweet spot by setting the host name to "localhost" and leaving the port number field blank, allowing Aptana to pick its own value.

Thursday, May 17, 2007

RailsConf2007 Day 1 - Rails Guidebook Charity All-Day Tutorial

Partook of the all-day tutorial put on by Dave "that's Roootes" Thomas and Mike "it's Rowtes" Clark. It would have been a lot more enjoyable if I'd managed to sleep more than 2 hours last night, probably just keyed up from the 6.5 hour drive from Vancouver, 4 cups of coffee and jitters about how to keep my spand-branking new laptop from disappearing - it's my first one, can you tell?

One key point Dave and Mike emphasized early on was that most of Rails is Ruby code, so the framework should really be called "Rails on Ruby". In short - if you want to understand Rails, you've got to understand Ruby. This point was reiterated at the break by newly-met lunchmates as we ate the not-too-bad box lunch in the cavernous exhibit hall. They agreed that David A. Black's book "Ruby for Rails", while slightly outdated (Ruby 1.8.4, Rails 1.0), demystifies the "magic code" in Rails by explaining the key Ruby concepts and structures underlying Rails.

Some observations:
  • Upon a show of hands, the audience was split about even between those who had written at least one Rails app, and those who were just getting their feet wet. I saw only one hand go up in response to the question as to how many participants were "super-comfortable" coding Ruby.
  • After reading the lively discussion on Ruby and Women following Gregory Brown's post, I was expecting a 90%+ male audience, however the gender split in the tutorial audience was more like 80/20, some improvement over the anecdotes in the discussion.
  • Also well applauded was the news mid-afternoon that the tutorial attendees had raised over $12,000 for the charities nominated on Pragprog's Justgive.org donation page.
  • On a dimmer note, I was pretty chuffed that the organizers didn't do more to provide AC power throughout the room. I managed to piggyback on the third or fourth power bar daisychained from one of the few wall outlets thanks to a generous neighbour.
The Mike 'n Dave show was very well put presented, knitting together a few concepts that had been puzzling me, Nubie that I am, like "where does it all go?" and "how does the view get the data from the controller?". Much of this is explained in Thomas' book "Active Web Development with Rails", but somehow hearing him explain it made it clearer. Somehow.

So what about the tutorial content? The first third of the day was a whirlwind introduction to and overview of Ruby, followed by a dissection of an example Rails app, with a potpourri of topics like migrations, REST and Capistrano rounding out the day.

Sunday, February 18, 2007

AWebFactory - a helping hand for RadRails

jEdit + RubyPlugin is a great, simple Rails development tool, but I was getting annoyed today by the need to open two console windows (one to run Mongrel, another to do rails config or rake work), a Web browser and jEdit, then cd to the depot application folder and manually fire up the Mongrel server every time I wanted to do a little more work on the AWDWR depot tutorial.

I thought about writing up a Windows batch file to start up all this stuff for me, then I realized that I would be cobbling together more or less the environment RadRails provides out of the box.

Since I was well into the depot demo application I wanted to import it to RadRails. A quick Google search let me to Victor Kane's AWebFactory - an amazing resource if you want to use RadRails while following along in AWDWR. Even more so, Victor illuminates many of the darker corners of MVC, OO and Rails that beginners might struggle with. Thanks for taking the time to write this invaluable guide, Victor!

Update (14 May 2007): Aptana has taken over development of Radrails, slowly integrating it into their Eclipse-based Web development IDE. The Aptana team and community are breathing new life into Radrails.

Thursday, February 15, 2007

Found a sweet spot!

Wolfman has posted some great stuff at the intersection of jEdit, Rails and HAML, especially the set of Superabbrev shortcuts for Rails development!

Sunday, February 11, 2007

Ruby on Rails for enterprise gaining ground?


I work for a big systems engineering firm (big by Canadian standards) with over 30 years of system and software engineering success. Much of that success is attributed to the company's conservative, risk-averse engineering culture. Nonetheless, a few brave souls within the company are embracing and succeeding with Agile ways. Ruby on Rails promises to ratchet Agile productivity up a notch or two, even for conservative, risk-averse enterprise projects.

In December 2005, Quoted-Printable published a link to a thought-provoking article by Obie Fernandez on the business value of Ruby on Rails. Fernandez predicted a big gain for RoR in 2006, thanks to the "productivity arbitrage" gains of RoR . So, did RoR gain ground in 2006? Was Fernandez on the money? Here's my totally unscientific search for the truth:

David Heinemeier Hansson first released Rails to the world in July 2004. According to a graph produced on Google Trends, the phrase "Ruby on Rails" makes its first appearance in Google searches in early 2005, climbs steadily through the rest of the year, then declines in 2006. Google provides no scale for the number of hits in the vertical scale (there must be a more scientific term for this), so all of the comparisons that follow are relative.

Over the same period, the terms "Java" and "J2EE" declined slightly on Google. A search for "Spring framework", representing the latest trend toward lightweight Java, shows a gain through 2005 followed by a marked decline in 2006.

So does this mean RoR is not gaining ground, or that web users are not searching for these terms as much as they first did, sort of a "framework fatigue" setting in?

Currently in a search for the term "Rails" on Google, eight of the first ten results are directly related to Ruby on Rails. The first five results point to Ruby on Rails-related sites, followed by Rails of Sheffield's "New and used model railways." The result may reveal more about Google's indexing algorithms than shifting patterns in the search term, but it provides some insight.

In the mean time, the first Railsconf in mid-June 2006, sponsored by non-profit advocacy group Ruby Central, sold out to an audience of 600. This year Ruby Central partnered with tech publishing behemoth O'Reilly to double the number of seats at Railsconf 2007 in Portland, Oregon.

Prompted by a fevered posting to the Rubyonrails weblog, last Monday, I succumbed to the hype and registered, even before I had the go-ahead from my employer's professional development program coordinator (yes, they have a great training and pro-D program!).

As of this posting, the conference is already three-quarters sold out, one week after registration opened!

Glad I bought my ticket early.

Sunday, February 4, 2007

require_gem is obsolete?

A discussion about the warning "c:0:Warning: require_gem is obsolete. Use gem instead". I couldn't get this one to work on my home box (Rails 1.2.1, Ruby 1.8.5 on Windows XP SP2) so I'm just ignoring it for now, hoping it's not critical. I'm still so new to RoR that I don't know what's important yet. I'm hoping the Ruby and RoR maintainers will fix this one soon?

Update (11 Feb 07): Rails 1.2.2, released on 6 Feb, fixes the problem, along with support for SQLite3 - you'll need gems 0.9.0 or better now.

Saturday, February 3, 2007

jEdit for Ruby on Rails

I received my copy of Agile Web Development with Rails yesterday, and eager to get started, I fired up my long-time favourite code editor, jEdit. Over the past five or six years I've used jEdit for just about every coding task I've ever undertaken, so I decided to try it out for Rails work.

After a couple of hours of downloading plugins and fiddling around with settings, I decided to save my notes here in the hopes that it would save you some time (and so I'd have it written down somewhere for the next time!). I'll assume you're starting from scratch:

  1. Download and install Exuberant Ctags (supports the CTagsSidekick plugin). According to the plugin docs, you need a recent version of this program.

  2. Check the system requirements for jEdit, then download and install the appropriate Java Runtime Environment.

  3. Download and install jEdit.

  4. If all is good, fire up jEdit, then select the menu Plugins -> Plugin Manager.

  5. Select the Install tab, then select and install the following plugins:

    • CodeBrowser: provides a tree view of the document structure

    • Console: integrated command-line with some smarts.

      • Doesn't work so well with applications that don't immediately flush their output buffer, e.g. for tailing WEBrick output.

      • Works well with the ErrorList plugin to highlight runtime errors in Ruby code.



    • CTagsSidekick: another, somewhat slicker document structure browser.

    • ErrorList: as the name implies, displays a list of errors generated by SideKick parsers

    • ProjectViewer: Best of the half-dozen project organization plugins. Some integration with console, e.g. switching the project view as you navigate the source tree in Console, or switch buffers in the main text edit view.

    • RubyPlugin: the big kahuna - makes jEdit a into real Rails locomotive :) I can't say enough about the features it provides, just read up on the author's site.

    • Sidekick: provides the framework for CTagsSidekick to do its magic.



    • XML: provides an HTML parser and tag completion facility for Sidekick



  6. Most of these plugins should install without a hitch. You might have to restart jEdit to let it find and install all of them correctly.

  7. Once all of the plugins are happily installed, select the "Plugin Options..." from the "Plugins" menu, then update the following plugin settings:

    1. Code Browser:

      1. Enter the path to the Ctags executable (e.g. on my system it's C:\Ctags\ctags.exe).



    2. Ctags Sidekick:

      1. Enter the path to the Ctags executable (e.g. on my system it's C:\Ctags\ctags.exe).

      2. Set "Group tags by" to "namespace (multi-level)"

      3. Click "Show icons" if it isn't selected.



    3. SideKick:

      1. In the Parsers section, set "rhtml" mode to the "html" parser, and "ruby" mode to the "ruby" parser.



    4. ProjectViewer:

      1. If you plan to use ProjectViewer to manage your Rails projects, add *.rb, *.rhtml and *.yml to the "Files to import" field of the "General Options" section.



    5. Click "OK" to save the settings and close the Plugin Options window.



  8. Select "Global Options" from the Utilities menu, then update the following settings:

    1. Editing:

      1. Select "html" from the list of modes.

      2. Uncheck "Use default settings".

      3. Add "rhtml" to the "File name glob" field, like so: *.{html,htm,hta,rhtml}



    2. Shortcuts:

      1. Select "Plugin: RubyPlugin" from the "Edit Shortcuts" list, then add the shortcuts as suggested on the jEditPlugin Features Page.



    3. Click "OK" to save the settings and close the "Global Options" window.



  9. Also see the excellent tips on Eadz's Ruby on Rails on jEdit page, and this howto on setting up RoR abbreviations.

  10. Best to restart jEdit so the buffer mode changes take effect.

    • You can confirm the mode is HTML by opening a .rhtml file then checking that HTML mode is displayed in the status bar, e.g. "(html,indent,Cp1252)".

    • Also, select the "Beautify Buffer" command from the menu Plugins -> Beauty. It should tidy up the HTML formatting.

    • Finally, a list of HTML tags should pop up when you type an opening tag bracket "<".

    • Sometimes jEdit "forgets" the mode it's using. Just restart it - it will remember where you were editing the file and which files you had open. Sweet.




That's about it. I welcome any and all corrections or additional tips!