BaseApp: a quick start for your Rails App
For the impatient: http://github.com/ariejan/baseapp
Got issues? Feature requests or patches? http://baseapp.lighthouseapp.com/
Every Rails developer has at least once developed an application that needed user authentication and some basic UI features like tabs and a sidebar. Ask yourself now: “how often have you installed and extended the restful_authentication plugin?”.
Yes, I have done it quite a few times and everytime I find myself writing the same code over and over again. User login, password reset, ‘forgot password’ functionality. I’ve build the same basic UI over and over again. Added administrator users and roles.
Are you tired of doing the same old things over and over again? I was! So, I created BaseApp.
BaseApp is a Ruby on Rails application which contains a lot of code you want in your project by default. To give you an idea of what is does out of the box:
- User Authentication including password recovery, account activation and account suspensio.
- Admin interface where the admin user can easily manage users and tweak app settings
- Default CSS-based UI with tabs and a sidebar. Very acceptable by default and easy to customise.
BaseApp is currently based on Rails 2.1.1. And although it’s a pretty complete package and ready to be used for your next project, it still needs a bit of work. Check out the README for features that should be in BaseApp.
Of course, BaseApp is open source so fork a copy at the GitHub and send me those patches (of pull requests)!
There are tons of feaures that can be included into BaseApp, so the next big thing is to include some sort of configuration that allows you to disable/enable certain BaseApp features.
So, go right ahead! Use it! Fork it! Send me those pull requests!
imagemagick libMagickWand magick Rails rmagick Ruby Ruby on Rails RubyOnRails
by Ariejan de Vroom
leave a comment
Debian Etch: RMagick LoadError
If you’re on Debian Etch, you may encounter the following error
libMagickWand.so.1: cannot open shared object file: No such file or directory - /usr/lib/ruby/gems/1.8/gems/rmagick-2.3.0/lib/RMagick2.so
This basically means that the libMagickWand.so.1 file cannot be found. However, it is available on your system. All you need to do to fix it, is tell your box to look in the right place for the file.
To fix this issue once and for all, open up /etc/ld.so.conf.d/whatever_file_is_here. The whatever_file_is_here is named after the kernel you have installed.
In this file, add the following line at the bottom
/usr/local/lib
Save the file and next run the ‘ldconfig’ command. This will reread the configuration file you just edited. Now, restart your Rails app and you’ll notice the error is gone and all is good again.
ldconfig
This change will be kept after you reboot, so you won’t encounter this error any time soon again.
Plugins Rails Ruby Ruby on Rails Throttler Throttling
by Ariejan de Vroom
leave a comment
Ruby on Rails plugin: Throttler
For those of you who have missed it: I’ve released a plugin yesterday that allows you to throttle your Rails app.
Read the original announcement and installation/usage instructions
Read how you can put Throttler to good use in your app
bdd Rails rspec Ruby Ruby on Rails RubyOnRails tdd testing
by Link Pilot
leave a comment
RSpec 1.1 Released: Now Supports Rails 2.0
The team behind RSpec, a Behavior-Driven Development based “testing” library, have announced the release of RSpec 1.1.0. This will be of particular interest to Rails 2.0 developers as support has now been added, along with interoperability with Test::Unit. RSpec 1.1 also includes a Rails tool called “RailsStory” that allows you write “user stories” that can be tested out on the fly.
cache find join order Rails Ruby Ruby on Rails select sort
by Ariejan de Vroom
2 comments
Rails: calculated column caching
Sometimes you’re working on a Rails project and you think: “hey! This should be easy!”. Well, most of the time it is. I’m working on a project that allows people to rate objects (what they really are doesn’t matter at all).
I’m using the acts_as_rateable plugin which creates an extra database table containing all ratings. I also have a table with my objects. Using the plugin I’m now able to do the following:
obj = Object.find(:first) obj.add_rating Rating.new(:rating => 4) obj.add_rating Rating.new(:rating => 5) obj.rating => 4.5
This works all perfectly, until you want to sort objects by rating. You could construct a huge SQL query to join the two tables, but that’s not really efficient, especially when your database gets bigger.
The solution is very easy and even more elegant. Use a cache! For this, you’ll first have to add a new field to the objects table. Do this in a migration:
add_column :objects, :rating_cache, :float
Now, in the Object model, add the following method:
def rate_with(rating) add_rating(rating) update_attribute('rating_cache', self.rating) end
You’ll need to change your controller from using #add_rating to #rate_with. The syntax is exactly the same. Now, when you add a rating, we also store the average rating in the rating_cache column.
To get back to the sorting problem, you can now use the rating_cache column to sort Objects.
Object.find(:all, :order => 'rating_cache DESC')
Of course, you can use this trick on all sorts of relations. Have fun with it.
RailsJobs.nl - Ruby on Rails Jobs in The Netherlands
The time is now ripe to announce RailsJobs.nl - A shiny new jobboard for Ruby on Rails developers who are seeking a job in the Netherlands or Belgium. I started the site a few days ago and business and job seekers have started to find RailsJobs.nl.
If you’re a business looking for Rails developers, feel free to add your job now. Use the code ‘RJINTRO’ to get a free 30-day trial period.
RailsJobs.nl is a private site, which I developed during the weekend. At first I planned the site to be free for all, but I’ve decided to charge businesses for posting jobs. This will ensure no spam, and only quality job offerings. It will also help me cover hosting bills and I can invest some of the money in advertising the site on quality websites.
Well, I’m not sure what to say more. Just hop over to RailsJobs.nl and see for yourself.
Oh, I have implemented a handy RSS Feed as well, so you can easily stay up to date on new job offerings.
