Skip to content

Instantly share code, notes, and snippets.

Get list gemset

rvm gemset list

Empty list gemset

rvm gemset empty [gemset_name]

Rails Admin field configuration

rails_admin do
  list do
    field :customfield do
      def value
        bindings[:object].your_method
      end
    end
 end

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)
  • P/s: should use ActiveRecord + carrierwave
  • 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

How to make web fonts work on Heroku

Add the fonts path to your production.rb and development.rb

# Add the font path
config.assets.paths << Rails.root.join('app', 'assets', 'fonts')

# Include font files to Assets
config.assets.precompile &lt;&lt; /\.(?:svg|eot|woff|ttf)$/

In your logged_in_controller.rb

class LoggedInController < ApplicationController
  before_filter :authenticate_user!
end

In your logged_in_controller_spec.rb

Heroku Mailer (SendGrid) configuration steps

  • Go to your heroku application.

  • Add SendGrid addons

  • Config STMP settings to your config/environment.rb

ActionMailer::Base.smtp_settings = {
@ivan22
ivan22 / RailsAdmin.md
Created May 17, 2014 03:06
Rails Admin

Extracting model configuration

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

# app/models/concerns/rails_admin/booking.rb
module RailsAdmin::Booking
@ivan22
ivan22 / Bootstrap v3.md
Created May 17, 2014 03:07
Bootstrap v3

Useful links:

Adding Bootstrap to Rails

  • Download Bootstrap
  • Copy bootstrap/dist/css/bootstrap.css and bootstrap/dist/css/bootstrap.min.css to vendor/assets/stylesheets
  • Copy bootstrap/dist/js/bootstrap.js and bootstrap/dist/js/bootstrap.min.js to vendor/assets/javascripts
  • Update app/assets/stylesheets/application.css *= require bootstrap
  • Update app/assets/javascripts/application.js //= require bootstrap
@ivan22
ivan22 / Macbook Setup.md
Created May 17, 2014 03:11
Macbook Setup - Recipe to setup a macbook with Rails and everything...