HowTo: Import your posts from Blogspot/Blogger

I needed to import blogspot blogs into a different system. I created a plugin that simply parses the xml file that is generated when you export your blogspot blog. Here is the link to github.

HowTo: Check if email really exists

I had a project that wants to check if an email really exists. Here’s what we came up initially. We ended up not using this in production though, but it’s a great tool.

HowTo: Authorize.Net CIM and ActiveMerchant

I’ve started working on a Sample Rails App that uses ActiveMerchant to connect to the Authorize.Net API. Here’s the link.

HowTo: Integrate with ConstantContact

I’ve started working on a plugin for ConstantContact. You can find the latest development here.

I hope you find it useful in integrating your Rails Apps with ConstantContact.

Rescue :me

These rescuers are quite handy to prevent nasty errors in production.

# in application_controller.rb
rescue_from ActionController::RoutingError, :with => :route_not_found
rescue_from ActiveRecord::RecordNotFound, :with => :record_not_found
rescue_from ActionController::MethodNotAllowed, :with => :invalid_method
rescue_from NoMethodError, :with => :show_error
rescue_from ActionView::TemplateError, :with => :template_not_found

private

def route_not_found
render :text => ‘Sorry, we could not find what you were looking for.’, :status => :not_found
end

etc.

HowTo: Changing the column name in a model for validation

Sample code taken from here.

class User > ActiveRecord::Base

HUMANIZED_ATTRIBUTES = {
:email => “E-mail address”
}

def self.human_attribute_name(attr)
HUMANIZED_ATTRIBUTES[attr.to_sym] || super
end

end

String#present?

>> “brain”.present?
=> true

>> “”.present?
=> false

use something.present?
instead of !something.blank?

Follow

Get every new post delivered to your Inbox.

Join 716 other followers