Tutorials

The following post will cover the method of uploading documents in Ruby on Rails. When I was initially looking into doing this I could only find tutorials that covered the uploading of images. Eventually I found the attachment_fu plugin that allowed for uploading of multiple file types. Firstly, we will need to install the plugin (windows users read this first).

(more…)

Although there are a number of good examples of how to send email through Ruby on Rails, I thought I would cover it so that any future topics on emailing have a reference point.

Our first step is to change some settings in the development environment. For the purpose of this tutorial we are going to use smtp settings for the setup.

# config/environments/development.rb
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  :address        => 'smtp.yourdomain.com',
  :port           => 25,
  :domain         => 'www.yourdomain.com',
  :authentication => :login,
  :user_name      => 'username',
  :password       => 'password'
}

(more…)

An association is a way of relating models/tables/objects together. Associations are a vital aspect of a Ruby on Rails application. Without them, the data will have no relationships and will ultimately be useless. The two most common associations are has_many: and has_one:. This post will cover the more complex associations has_and_belongs_to_many and also has_many :through. Both of these methods are for many to many relationships. For this tutorial, we will use the below models from a “Library” application:

  • Books
  • Customer

A customer can hire many books, and a book can be loaned by many customers.

(more…)