Skip to content

Instantly share code, notes, and snippets.

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!

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
@jamesfwz
jamesfwz / Postgres.md
Last active August 29, 2015 14:02 — forked from stevenyap/Postgres.md

Setup Postgres in Server

rpm -i http://yum.postgresql.org/9.2/redhat/rhel-6-x86_64/pgdg-centos92-9.2-6.noarch.rpm
yum -y install postgresql92-server postgresql92-contrib postgresql92-devel
yum -y install postgresql-devel # this is for gem pg

service postgresql-9.2 initdb
chkconfig postgresql-9.2 on
service postgresql-9.2 restart

Note: You need to have to Heroku PGBackup addon first heroku addons:add pgbackups..

Importing Heroku PG DB to local

Creates the backup on heroku first:

heroku pg:backups capture
@jamesfwz
jamesfwz / Gemfile
Created June 10, 2014 03:34 — forked from ivan22/Gemfile
Carrierwave
# ...
gem 'carrierwave'
gem 'fog', '~> 1.0.0' # Need to specify version, as carrierwave references older (0.9.0) which doesn't allow configuration of Rackspace UK Auth URL