Rails on GIT

Posted by stoyan

Semi-official Rails GIT repositories, maintained by Michael Koziarski :

$ git clone git://github.com/NZKoz/koz-rails.git

Update 13-Mar-2008: Steve’s git-svn mirror of the Rails repo (see the comments)

git clone git://git.sanityinc.com/rails.git

Joyent Facebook Developer Accelerator

Posted by stoyan

Got my own Joyent Facebook Developer Accelerator . Will try to put some Merb application on it. To read:

Rails 2.0 Preview Release

Posted by stoyan

Tried the new Rails version. After
$ rails rls20PR && cd rls20PR
$ rake rails:freeze:edge TAG=rel_2-0-0_PR
$ rake rails:update
for every rake task i’ve got:
rake aborted!
no such file to load -- active_resource

The problem

edge_rails requires ActiveResource, and the rake freeze:edge:rails don’t checkout it.

The solution:

$ svn co http://svn.rubyonrails.org/rails/trunk/activeresource vendor/rails/activeresource
$ script/about
...
Edge Rails revision       7712

Update 04-Oct-2007 : via s.ross post to the “Ruby on Rails: Talk” Google Group:

Do another rake rails:freeze:edge. I know it sounds strange, but the first one installs a lot of the edge version as well as the Rake tasks. The second time you do it, the new Rake task knows enough to grab ActiveResource.

So the right procedure is:
$ rails --version
Rails 1.2.3
$ rails rls20PR && cd rls20PR
$ rake rails:freeze:edge TAG=rel_2-0-0_PR
$ rake rails:update
$ rake rails:freeze:edge TAG=rel_2-0-0_PR
Update 05-Oct-2007 : Another way to have a fresh rails2 directory:
$ sudo svn co http://svn.rubyonrails.org/rails/tags/rel_2-0-0_PR /opt/rails2
$ ruby /opt/rails2/railties/bin/rails rls20PR
$ cd rls20PR/vendor
$ ln -s /opt/rails2 rails

Rubygems on Debian "one-click installer"

Posted by stoyan

Rubygems on Debian “one-click installer”

Before I mentioned Rails on Debian ‘one-click installer’ . Seems there is also a way to install ruby gems with apt-get on debian-like systems . It’s in japanese, so just a short translation:

Add to your /etc/apt/sources.list :

deb http://backports.mithril-linux.org sarge-backports main contrib non-free
deb-src http://backports.mithril-linux.org sarge-backports main contrib non-free

Add to your /etc/apt/preferences :

Package: rubygems
Pin: release a=sarge-backports
Pin-Priority: 900

Install rubygems:

apt-get update
apt-get install rubygems
The rubygems are installed in /var/lib/gems so we need to change the PATH environment variable in order to access gem command. Inside /etc/profile :
export PATH="/var/lib/gems/1.8/bin:$PATH" 

Install rails

gem install rails -y

Offtopic: ...No longer will we have to use RESTful URLs such as article/1;edit. We’re going back to the more normal-looking article/1/edit …

OpenID in Edge Rails

Posted by stoyan

So we got millions of people with an OpenID by virtue of their AIM account. Great. Now they just need a place or two to actually use it. —DHH

changeset 6245Added simple OpenID authentication Rails plugin wrapper for ruby-openid

See also: There is already a lot of OpenID providers:

Cookie Based Sessions in Current Rails

Posted by stoyan

Seems Cookie Based Sessions are the New Default in Edge Rails : ...Cookie-based sessions are just faster to retrieve and process than hitting the file-system on every request. Plus, I would imagine they scale considerably better as they’re persisted on the client side and have no server-side persistence requirements…

So I made a cookie-based sessions patch agains current Rails (actionpack-1.13.2). Usage (from inside your project):
rake rails:freeze:gems
cd vendor
wget http://zhware.net/code/ruby/ror/session_store-1.13.2.patch
patch -p0 < session_store-1.13.2.patch

Keeping Rails running at Dreamhost Part 2

Posted by stoyan

origin: gabito.com blog post

...I’ve finally gotten my 500 error rate down to 0 by making some minor changes to the signal handling code of dispatch.fcgi. If the dispatch.fcgi process is in the midst of handling a request I defer letting it be killed until the request is complete. I did this by installing a custom TERM signal handler that protects the dispatch.fcgi process while a request is being processed…

6th Kansai Rails meeting in Kobe

Posted by stoyan

After small timeout I found a time to put some notes for the last Rails meeting in Kobe .

Sometimes StikiPad is down (specially when i need my notes ;) ), so like a work around will try to duplicate all notes on the self-hosted Junebug -powered wiki . For the related discussions there is a Beast -powered forum . Hahahah (c) Powered by RoR site a ;) The only missing part is maybe Mephisto for blogging. Or I can use my homemade Restolog when it’s ready.

nginx notes

Posted by stoyan

I put some notes for nginx on my wiki .

The rails system administration is like waves – somebody found a new software and the community just fulfill it. Maybe there must be some name for this effect. Something like digg-effect but maybe Rails wave hahaha.

First there was lighttpd , now nginx comming. Maybe your piece of code will be the next. Are your ready? ;)

Restolog-1.2 (beta1)

Posted by stoyan

Created a first beta version of Restolog-1.2 . What’s new in it:
  • Textile markup for articles body (act_as_textiled plugin)
  • REST client (‘script/rester’)
  • New REST API calls added (mostly for articles and comments)
  • Some documentation (README, USAGE, CHANGELOG)
Download:
  • tarballs: restolog-1.2b1.tgz
  • SVN: svn checkout http://restolog.googlecode.com/svn/trunk/ restolog
Why it is still beta?
  • update via XML still do not work
  • authentication via keys inside the URL still not possible (Basic Authentication for now)

And by request from Benjamin there is pretty detailed Restolog USAGE file included. Enjoy

Restolog - RESTful blog example

Posted by stoyan

I modified a little the original Alisdair McDiarmid’s RestBlog sources and created very simple blog system . Made an announce to the Rails ML. The copy of it follows:

Very simple blog system based on REST/CRUD ideas. Sources (all credits going to the authors, i just combined their work):

The purpose is mostly proof of concept, not typo/mephisto etc. competition.

ActiveMailer sending via GMail

Posted by stoyan

On the previous Kansai Rails Conference in Asiyagawa somebody asked me about using GMail (smtp+ssl or tls) with Rails ActiveMailer. Didn’t find solution until now but ‘dza-dza-dzaaaaaaan’ (hahaha i’m not so smart, all credits going to entombedvirus ):

Send email with ActionMailer through TLS only SMTP server

So for Debian (Ubuntu):

Install msmtp (light SMTP client with support for server profiles)

$ sudo apt-get install msmtp

Create/edit ~/.msmtprc

account gmail
host smtp.gmail.com
auth on
user <your_account>@gmail.com
password <your_password>
tls on
tls_starttls on
from <your_account>@gmail.com
maildomain gmail.com
account default : gmail

Stop msmtp complaining about permissions

$ chmod 600 ~/.msmtprc

Add on the bottom of yourrailsapp/config/environment.rb (and comment another ActionMailer::Base.delivery_method settings if exists)

ActionMailer::Base.delivery_method = :msmtp

module ActionMailer
  class Base
    def perform_delivery_msmtp(mail)
      IO.popen("/usr/bin/msmtp -t -C /<path_to>/.msmtprc -a gmail --", "w") do
 |sm|
        sm.puts(mail.encoded.gsub(/\r/, ''))
        sm.flush
      end
    end
  end
end

Do not forget to fix the exact path to your .msmtprc in the source above.

WebDAV Ruby On Rails Plugin

Posted by stoyan

Via liverail.net :

I’m releasing the first version of the RailsDAV plugin . What does RailsDAV do. Well it allows people to create Ruby On Rails controllers which will respond to WebDAV requests and expose functionality as a file-system.

Uhoo, finally. Now I can access my Rails applications not only with browser, but also mount them from the OS X Finger or like Windows Network Disks.

Pretty cool. I’m waiting also for the changes in the Rails itself, to support PUT and DELETE in addition to GET and POST, changes DHH promised to us in Tokyo.

Litespeed+mongrel+HTTPS

Posted by stoyan

Great news from LiteSpeed Technologiesafter a post to the forum they have “X-Forwarded-Proto: https” AUTOMATICALY added to the headers, when proxing requests, initially comming via HTTPS. Now Rails applications are not confused, when doing redirects for HTTPS. Good to be added to Litespeed+Mongrel docs .

The litespeed-2.1.17 is already available for download (even still there is no announce).

Discovering a world of Resources on Rails

Posted by stoyan

The best DHH presentation on RubyKaigi2006 ”summary”. Man, it’s not a summary, it just the whole presentation, word by word, translated in japanese with sources, pictures etc.