Genuity Tech Blog

Tidbits of Ruby, Rails, and all things related

Page title for custom ActiveAdmin actions

I recently needed to customize the page title of a custom ActiveAdmin action. This is how I did it:

1
2
3
4
5
ActiveAdmin.register Customer do
  collection_action :import do
    @page_title = "Import Customers"
  end
end

I got the idea after seeing this in the active_admin source:

ActiveAdmin::Views::Pages::Base#set_page_title GitHub
1
2
3
4
# Set's the page title for the layout to render
def set_page_title
  set_ivar_on_view "@page_title", title
end

If there is a better way to do this, somone please leave a comment. I’ve also updated the ActiveAdmin wiki page related to this.

Update: 2012-04-12

I’ve recently submitted a pull request to active_admin that will let you set the page title declaratively, staying consistent to how this is done for the other standard actions:

1
2
3
4
5
ActiveAdmin.register Post do
  collection_action :comments, :title => "My Awesome Comments" do
    # do stuff
  end
end

If this PR is accepted, this will be a better solution, and I will update this post as well as the ActiveAdmin wiki.

ActiveAdmin and CanCan

TL;DR

When using CanCan with ActiveAdmin, ability rules with conditons aren’t respected. This post talks about the customizations I made to get these rules to work in ActiveAdmin.



One of the projects I’m currently working on uses ActiveAdmin for the back end administration interface. I’ve used ActiveAdmin on several projects, and I really like it a lot. However, I always seem to find myself needing to go beyond the generated resource definitions and do some customization. On this particular project, I’ve had to do what I consider to be significant customization. The things I’ve had to do have either been not documented well by ActiveAdmin, or in some cases not documented at all. In an effort to help others, I’ve decided to write a series of blog posts on the customizations I’ve had to do to get ActiveAdmin to do what I need.

For this first post I would like to talk about using the popular authorization gem CanCan, written by Ryan Bates of Railscasts fame, for declaring authorization rules for the different user roles in this project’s admin interface.

Pinterest extension for Spree

TL; DR

spree_pinterest is a Spree extension for adding a Pinterest Pin it button to your Spree store. Install it by adding it to your Gemfile.



The last project I worked on, the client needed shopping cart capabilities added to thier site. I chose to use the open-source Spree shopping cart Rails engine.

Spree is a great piece of software that doesn’t try to cover every edge case in the e-commerce world. It provides what 98% of most sites need to run an online store. The last project I worked on fell within the other 2% though, and I had to heavily customize it for that particular project. I’ll save those customizations for another post.

What I want to talk about today is a new Spree extension I wrote recently, called spree_pinterest. It’s a simple extension that adds a Pinterest Pin it button to the Spree product index and show views.

Signing SOAP messages in Ruby using certificates

TL; DR

Need to sign SOAP messages in Ruby with a X.509 certificate? Check out our forks of Savon and Akami. I have to give credit where credit is due. @amiel with Carnes Media did almost all of the work. I just fixed a bug and updated their work to play nice with the latest version of Savon.



I’ve been a Ruby and Rails developer now for about 5 years. In that time, I could probably count on one hand finger the number of times I’ve had to consume a SOAP service. Ruby and Rails developers seem to avoid XML, and it’s ugly step-sister SOAP, like the plague.

Heroku Labs and user_env_compile

TL;DR

Heroku Lab’s user_env_compile feature reveals your app’s config vars at slug compile time. You have to first install the Heroku Labs plugin. Then enable the user_env_compile feature.



In case you missed it, Heroku recently announced the new Heroku Labs. As described in their email:

Heroku Labs gives you granular control over your use of experimental Heroku features. You can choose to turn individual features on and off as you need them.

One of the first features they rolled out, and one that’s of particular interest to me, is their user_env_compile feature. Enabling this feature will make your app’s config vars available at slug compile time. “Why is this important?”, you might ask? Well, one reason is if you are using the asset pipeline introduced in Rails 3.1.