Tag Archives: rails

Multiline Comments in Rails ERB Views

If you want to add multiline comments to your Rails .html.erb Views do the following. The =begin and =end need to be at the beginning of the lines for it to work! Also, you cannot have any ERB code in the =begin and =end blocks, if you comment this way. If you want to comment […]

Old Scaffold Problem on Lynda Ruby on Rails Essential Training

There are a number of people following lynda.com’s Ruby on Rails Essential Training tutorial and running into issues since some of the information in the tutorial is outdated. The method scaffold was removed from Rails 2.0. You can still create scaffolds but must do so by generating the scaffold files explicitly. If you see NoMethodError […]

How to Speed up Rendering pages which include lots of JavaScript

When referencing an external JavaScript file within the head tag of your HTML, the rendering of the page is halted while the external JavaScript file is downloaded and loaded. In order to speed up rendering of the page, you can move your javascript_include_tag from your head tag to the last line within your body tag […]

Avoid Duplication of Hash Options

There are lots methods in Rails where the last argument is a Hash. Sometimes the same Hash is passed into more than one method, causing you to repeat yourself. For example, when using validation helpers in your models, you may be doing something like this: Using with_options within a Model: Notice, :on => create is […]

Reusing database.yml Sections

In order to reuse database.yml sections for your database connection information, you can do the following in your database.yml file. Notice the use of &development which creates a tag which can be referenced later within your database.yml file. You can also do something like this, which assigns the &login tag which is later referenced within […]

will_paginate plugin – Installing and Sample Code

Installing the will_paginate Plugin You can install this plugin as a gem but in this example, I’ll install it as a plugin so it can travel with the rails application. This disadvantage of installing it as a plugin instead of a gem is that you’ll need to install it as a plugin for each rails […]

Rails Draggable Element Example – Scriptaculous Effect

This is a simple example of how to create two separate draggable elements using Scriptaculous Effect draggable_element. Here is what the end result will look like. Each box will be draggable. So once done, you’ll be able to drag each section and each section will remain on the screen where you leave it: Include default […]

Ruby Time formatting and datetime SQL Column

If you’d like to format Time in Ruby, keep in mind that datetime SQL Columns translate to Time objects. So you can use the strftime method of the Time class to format the date/time. For example, assume scheduled_time is a field in your database and it has a sql data type of ‘datetime’. In your […]

Set up a Rails project on BlueHost

Here are advantages to using BlueHost, in my opinion, for your RoR (Ruby on Rails) projects. However, you may have to do some of your own research sometimes, but I’ve been posting BlueHost related BlueHost How-Tos. Keep in mind that BlueHost support is not just focused on hosting Rails projects. Even still, I highly recommend […]

Deploying a Rails App, with Git and Capistrano on BlueHost

Here I’ll make an attempt to describe how to create a rails app from scratch on your local machine, configure a private Git repository on BlueHost and use Capistrano to deploy the latest code from the private shared Git repository. Almost all of the steps below work, except I’m still unable to deploy the code […]