Skip to content

Instantly share code, notes, and snippets.

These are steps to setup a new project in ROR.
You must configure and install your Gems individually instead of copying the Gemfile from a previous project.
Refer to Heroku setup if you want to push your project to Heroku.
## Setup directory
```sh
# Create directory in ~/workspace
mkdir ./testproject
cd ./testproject

Extracting model configuration

# app/models/booking.rb
class Booking
  include RailsAdmin::Booking
end

# app/models/concerns/rails_admin/booking.rb
module RailsAdmin::Booking
@jamesfwz
jamesfwz / RVM.md
Created June 17, 2014 10:38 — forked from ivan22/RVM.md

Installing RVM

# install RVM
curl -L https://get.rvm.io | bash -s stable

# runs RVM
source /etc/profile.d/rvm.sh

# Setups required files for RVM

Gemfile

gem 'simple_form'

Installation

rails generate simple_form:install

Gemfile

gem 'countries'

View

= select_tag(:country, options_for_select(Country.all))

Setup

  • Install the gem gem "paperclip", "~> 3.0"
# Create Database
class AddPhotoToDeals < ActiveRecord::Migration
  def self.up
    add_attachment :deals, :photo
  end

This gem makes creating cron jobs very easy!

  • Source: https://github.com/javan/whenever
  • After defining your crons, you need to run whenever -w to write out the crontab
  • Use crontab -l to see the list of cron jobs you have

Sample schedule.rb

set :output, {:standard =&gt; 'log/cron.log'} #logs to your log file to view

Setup a WYSIWYG editor with CKEditor. Includes instruction for Rails_Admin

  • Add gem 'ckeditor' to your Gemfile and bundle
  • Checkout https://github.com/galetahub/ckeditor for instruction to generate the correct model to generate for uploading of files (eg. ActiveRecord + Paperclip)
  • Run rake db:migrate
  • Add //= require ckeditor/override in your application.js (before require_tree .)

To configure the editor to be used in Rails_Admin, follow this https://github.com/sferik/rails_admin/wiki/CKEditor

Sample Rails_Admin model config

This guide setup Apache2/Passenger/Ruby/Rails on a CentOS 6.4 LiveCD.
You can test it yourself using VirtualBox to run all the scripts - read VirtualBox.md for more info.

# install the necessary libraries
yum clean all
yum -y update
yum -y install curl-devel git sqlite-devel libxml2-devel
yum -y install libxml2 libxml2-devel libxslt libxslt-devel
yum -y install gcc-c++ readline-devel libyaml-devel libffi-devel openssl-devel libtool bison