Creating Edge Rails Apps Made Easy
December 10th, 2006 -
Update: I’ve made some updates the the script that I find useful for myself. The script will erase the README file in the root directory of the rails app, create a CHANGELOG file, add screen.css to the public folder, application.rhtml to the app/views/layouts folder, creates the database.yml.sample file in the config folder and edits the database.yml file to the way I like it to be. Calling the script has changed as well: ./set_rails myappname postgres. Basically, myappname is the name of the app and postgres is what database you are going to use for you application. It will set the database.yml file for you. You’ll just need to add your username and password for the database.
I am a huge fan of using edge Rails for all of my development work, when working with Rails. I also have a typical list of plugins I almost always use for my applications that I build. Creating the app on edge Rails, adding all the plugins, and then getting it all setup on subversion can get quite monotonous.
I’ve been wanting to take some time out and write up a bash script (sorry windows people) that will do all of this for me, thus being a painless process. It is DRYing up the process of creating a Rails application on the edge.
It currently doesn’t include adding to your subversion repository, something which many variables will be different for everyone. Here is how to use this script:
cd into the the directory where your rails application will reside. Not that actual Rails application directory, but the parent directory of the soon to be created Rails application. This script will create your Rails directory for you with the name you pass to the script.
To create your Edge Rails application, type the following into the prompt (this is a bash script):
chmod 755 set_rails
./set_rails your_application_name postgres
Replace your_application_name with the name that you want to name your Rails application directory and either keep postgres the same or replace it with something else like mysql or sqlite. That second variable will set your database.yml file to use that specific database. All you need to do is open up database.yml and add your username and password for your database.
Sit, back, browse the web, get some coffee, or put your feet up and watch it create your whole Rails application structure on Edge Rails for you. Also, it will install the following plugins:
- RESTful Authentication
- Acts as Versioned
- Acts as Paranoid
- Acts as Attachment
- Acts as Taggable
- Account Location
- Resource Feeder
- Upload Progress
- Simply Helpful
- TZInfo Timezone
- Exception Notification
- Continuous Builder
- To_CSV
- Annotate Models
- Routing Navigator
As you can see I have a lot of Rick Olson’s plugins and the Rails Core Team’s plugins.
Grab the file and enjoy! Let me know what you think and what I might have missed or you would like to see.
Tags: development, rails 101
Comments
Robert
December 10th, 2006
I’ve added links for each plugin to the plugin repository. To learn more about the plugin, most have a read me file within the plugin itself that shows you how to use it. vendor/plugin/restful_authentication/ is an example of where the read me files usually are.
Also, sometimes the read me files are blank or non-existent but the code itself within the plugin give examples of how to use it. And some just don’t have documentation which is sad for people who are new and want to try them out.
Ryan Heneise
December 11th, 2006
This is incredibly slick and helpful! I’ll be using this from now on. I can’t think of anything I’d add, though I’ll let you know if I do.
Mark Priestap
December 11th, 2006
Nice work bro!
topfunky
December 11th, 2006
Tim Lucas also has a similar recipe. Maybe this could be combined with the RailsMachine capistrano task that also creates a subversion repo and imports the app for the first time? Or maybe that’s overkill.
http://toolmantim.com/article/2006/12/7/a_clean_slate_edge_rails_recipe
Robert
December 11th, 2006
Ryan/Mark: Thanks guys. I hope this is helpful for many people out there who just get tired of going through the process of creating a rails app. I wouldn’t suggest someone use it who doesn’t already know how to create an app and install plugins.
Geoff: I have a svn script I am working on and was debating on whether or not to include it within this script itself. Adding some capistrano magic would be quite cool though.
Chad H
December 14th, 2006
You may want to consider making a rapt plugin pack if you install those very often to make installation even simpler.
Robert
December 14th, 2006
Chad: Thanks for the idea! I might write one where you can add in your RaPT as a parameter that way you aren’t limited to what I use, but can have the script setup what each individual uses. (assuming people are using RaPT) How does that sound?
Antonio Eggberg
December 18th, 2006
Hi:
Thanks! A quick question (I am not savvy subversion user!) why are you using ‘svn export’ instead of ‘svn checkout’ .. I mean in such case I could just update the trunk as offten as they make changes no?? How do you deal with changes while you are working on projects.. I mean do I need to move the contents of app/ test/ from my edge development prior to update?
Thanks again you saved me a lot of time!!
Robert
December 18th, 2006
I’m using svn export because I eventually erase the vendor/rails directory upon committing it to subversion for my project and I set svn propset svn:externals “rails http://dev.rubyonrails.org/svn/rails/trunk” vendor. That way, each time I check out my project from subversion, it checks out the latest edge rails as well.
The same thing can be done with all the plugins as well, but since those are updated less frequently, I didn’t really see the impending need to include that.
I’m currently writing another script (lately I’ve been too slammed to work on it) that will deal with all the SVN stuff. Also, I’ll be tinkering with this script to add in RaPT support.
Kenny
December 24th, 2006
Great idea Robert. I converted it to a ruby file so that our windows friends could play along too. I also added some error checking. I didn’t include all the plugins that you did, but other than that the experience should be the same.
http://kennethparnell.com/files/edge_rails.rb
Robert
December 25th, 2006
Nice Kenny!
Ed
December 30th, 2006
Kenny: I had to insert “ruby ” at the beginning of the ”./script/install” exec command to get it to work on my WinXP box. After that, it ran like a charm!
Thanks!
P.S. As I read this blog entry and its comments, I was thinking, “now why didn’t Robert write this in Ruby?” ;) Then I read your comment and downloaded your Ruby script! :)
Robert
January 3rd, 2007
Ed: I know, I probably should have written this in Ruby initially, but I’ve been wanting to work to write more bash scripts, hence the use of bash. Also, I have some plans for this script in the future, which means it won’t stay in a shell script. I want it to become as portable and generic as possible.
Kenny
January 3rd, 2007
Ed: Thanks for the heads up. I can’t believe I missed that one. I guess I’ve been in *nix world too long.
Commenting has been turned off.
Yannick
December 10th, 2006
Decided to try and it and it worked like a charm Robert. Thanks for sharing this handy little script. Being a rails newbie though, could you give a link to the plugins so I can find out some more about what they do? Something with a brief description maybe? I found the plugins by Rick on his site, but still not quite sure what some of them do. :)