Howto manage an svn+edgerails+capistrano environment on Gnome/Linux




gedit rails svn scripts
 I found on internet a lot of informations about how to install something-in-rails but I didn't find a real world usage of it.
What I've written is an overview about how to be productive with rails in a quite common use case. This "ecosystem" is mainly for rails projects, but can be used also for other kind on applications.  

Install svn

Subversion is a very common version control system; sometimes it's installed in your web hosting space, but if you decide to set up on you PC you are more indipendent.
 sudo apt-get install subversion subversion-helper-scripts subversion-tools 
You have to create the directory for the svn projects

# '/svn-stuff' is where you put your config and svn internal stuff
sudo mkdir -p /svn-stuff
sudo svnadmin create /svn-stuff
-- sudo gedit /svn-stuff/conf/svnserve.conf
[general]
anon-access = read
auth-access = write
password-db = passwd # relative path to the users file
--

-- sudo gedit /svn-stuff/conf/passwd
[users]
username = password

--

Start svn server (called svnserve) with:

svnserve -d -r /svn-stuff
# it means 'daemon' and svn projects path

There's not a '/etc/init.d/svnserve start' script but you can start automatically svn server with xinetd

For more informations see Ubuntu forum and if you need the http interface you can install websvn

WARNING

+ Everything should go as expected, if you get something like "svnserve.conf:28: Option expected" probably you have to delete the space before a parameter like anon-access
+ You can start svnserve with -i, but It didn't work for me

Install edgerails environment

It's very easy to do 'gem install rails' but if you want lastest stable release or your web hosting doesn't update rails frequently this is the best thing to do.
We will keep latest rails in a directory called edgerails and all the apps we'll create will point the first rails path MYRAILSAPP/vendor/rails -> to edgerails/ So edgerails will be shared.

# '/projects' is the path to the dir where you store your apps
cd /projects
svn co http://dev.rubyonrails.org/svn/rails/branches/stable/ edgerails/
#This alias is to have edgerails as default rails
alias rails="ruby  /projects/edgerails/railties/bin/rails"
rails eapp
cd eapp/vendor/
ln -s ../../edgerails/ rails
cd ..
script/server # http://localhost:3000 and test rails version
# => Booting lighttpd (use 'script/server webrick' to force WEBrick)

cd ..

# It's the first import of the directory, and 'trunk' is the current release
svn import eapp svn://localhost/eapp/trunk -m "Import eapp"

# just to be secure that everything will go well anyway :)
mv eapp eappbak

# This will sinchronize the content with the current svn version

svn co svn://localhost/eapp/trunk eapp # with -r <number> you specify the release

#Test svn
cd eapp
echo "test" >> README
svn diff # differences with svn version
svn ci -m "added test ooh" # commit the changes to svn
svn up -r <number before> #rollback
# svn add file-or-dir # to add a file to svn

Common tasks

# -x automatically generates the svn code
script/plugin install -x acts_as_taggable
# -x automatically generates the svn code
script/generate model -c mymodel

Other stuffs

Capistrano permits to create tasks to manage your rails app
# Usually the web hosting already did this for you
sudo gem install capistrano --include-dependencies

cap --apply-to eapp
svn add config/deploy.rb
svn add lib/tasks/capistrano.rake
svn ci -m "added capistrano"
Install features for Gnome environment

nautilus svn scripts
to control common svn commands on a GUI!
sudo apt-get install nautilus-script-collection-svn
meld is a nicer way to see 'svn diff' with colors
edit the nautilus script 'diff' and put:
#zenity...
meld $@

Gedit rails, some basic autocompletion snippet for rails

Notes 

  • If you have enought RAM and CPU even Eclipse + Radrails + Subversive offers a nice environment.