Entries Tagged 'rails' ↓
December 10th, 2008 — administrate_me, open source, plugins, rails
As you well know administrate_me is our beloved plugin, and it’s about to reach its two years old (and one amazing year since we opensourced it). We never stop using it and I believe that’s the main reason why this plugin has grown that much this year.
With administrate_me, we’re able to build a production-ready backend in a couple of minutes. It 

simplifies almost any management task you need to build for a rails app, this way you can focus and put all your efforts into application’s frontend.
We’re almost done with administrate_me 2.0 version (I believe its release will be on or about December 18th), you can watch plugin’s progress on github (even you can push some patches).
For those who can’t wait til December 18th, here you have a little snapshot of administrate_me’s backend new look



We’re definately there! yay!
November 18th, 2008 — open source, plugins, rails, ruby
backup_fu is a nice Rails plugin to backup all your data to an S3 account. Sadly, it currently doesn’t work on windows.
Two bugs prevent it to run smoothly, first it depends on tar and gzip commands, which are not always available on that platform. Even though there are some native implementations, I’ve never found a tar one that I could actually use, most of them just fail at archiving big files. I’ve fixed this using the minitar gem to generate a tar.gz file from the sql dump.
On the other hand, there is an aws-s3 bug that prevents files to be directly passed to the store() method to upload the files. Fixing this was just a matter to read the file using ‘rb’ parameters for File.open().
You can see this and this commit with the changes, a pull request has already been sent.
November 13th, 2008 — open source, plugins, rails, ruby
The need for executing long task process is a common thing in large-scale rails projects these days. This is something any serious developer should be aware of. Make no mistake, long tasks can consume large amounts of servers resources, and they can provoke servers to crash when you request them via http.
A great solution for this problem is the delayed_job plugin by Tobias Lütke. This plugin is very easy to install, is very well documented, and provides you with everything you’ll need to execute task in background. I had the oportunity to try it out on burdastyle.com, and it worked just fine. So, congratulations Tobi for this great work and thanks for sharing.
So, let’s try delayed_job plugin out.
First thing we need to do after we install this plugin is to generate a migration to add delayed_jobs table into our database. This migration should look like this:
class CreateDelayedJobs < ActiveRecord::Migration
def self.up
create_table :delayed_jobs, :force => true do |table|
table.integer :priority, :default => 0
table.integer :attempts, :default => 0
table.text :handler
table.string :last_error
table.datetime :run_at
table.datetime :locked_at
table.datetime :failed_at
table.string :locked_by
table.timestamps
end
end
def self.down
end
end
Then, we’ll need to define our jobs. A job is just a ruby class with a method called perform. Let’s say we need to send a very simple email notification to our entire users database. We can use this little class:
class NotificationJob < Struct.new(:message)
def perform
total = User.count
limit = 100
(0..total-1).step(limit) do |offset|
User.find(:all, :limit => limit, :offset => offset).each do |u|
Notifier.deliver_message_to_user(u, message)
end
end
end
end
Now, every time you need to send these notifications out, you just enqueue your job like this:
Delayed::Job.enqueue NotificationJob.new("hello world!")
Finally, delayed_job plugin provides you with a set of rake tasks to put enqueue jobs to work:
rake jobs:work
And that’s all folks! Have fun with delayed_job.
Happy hacking!
September 29th, 2008 — administrate_me, open source, rails
You probably have already heard of BORT, its a Base Rails Application that you can use to bootstrap your project. Believe me, you will save a few hours on each project using it and will be able to jump directly to the fun part.
We wanted to use it too, but most of our projects include administrate_me, so the best thing we could have done is to keep ourselves DRY and fork BORT to create a version including an installed and bootstraped administrate_me by default.
You can check out here our BORT version. The same setup instructions apply as if it were a regular BORT app.
As a plus, this includes an updated version of rspec-on-rails-matchers plugin, which is something that is also catching on on all of out projects lately.
Feel free to clone it, fork it and send all kind of patches and pull requests.
September 27th, 2008 — administrate_me, open source, rails
Have you met administrate_me? (hint: The README file show’s you how to setup a rails app using administrate_me from from scratch) It’s Insignia’s plugin to handle our backend in the most agile and efficient way. You can see a simple administrate_me screenshot to check out what it looks like.
So, the news are that in a few hacking sessions we managed to create some rpsec shared behaviours and matchers to help you test your controllers that use administrate_me.
On this files you can see the actual code of the specs, but most important, clear examples about how to use them:
administrate_me Shared Behaviours: You can use them to check that your controllers are fully functional. It comes in two flavors: ‘basic administrate_me’ and ‘basic administrate_me with parent’ to test child controllers.
administrate_me Matchers: For now you have just two matchers to check for the order set and the fields on which the search is allowed. There are more matchers to come.
Now you dont have excuse for not testing your controllers!