Skip to content

Instantly share code, notes, and snippets.

@nbashaw
Last active August 29, 2015 14:03
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nbashaw/0adf9746ba9244ce5f19 to your computer and use it in GitHub Desktop.
Save nbashaw/0adf9746ba9244ce5f19 to your computer and use it in GitHub Desktop.
# Kickoff - the quickest way to start new rails apps
# How it works:
# 1. Install the gem: `$ gem install kickoff-rails`
# 2. Generate your kickoff file `$ kickoff new`
# 3. Edit the kickoff file to specify the foundation of your app
# 4. Generate your app: `$ kickoff`
# Set up default gems
gems = ['omniauth', 'omniauth-twitter', 'pg', 'airbrake']
# Define your models with ease
create_model do |m|
m.name :post
m.string :title
m.text :body
m.references :user
end
create_model do |m|
m.name :user
m.string :name
m.string :email
end
# Controllers & routes
create_controller do |c|
c.actions = [:new, :index, :show]
end
module Kickoff
class Model
def initialize(&block)
if block_given?
instance_eval(&block)
end
end
def name(model_name)
puts "Creating model: #{model_name}"
end
def field(type, name)
puts "Creating #{type} field: #{name}"
end
end
end
include Kickoff
# User model
Model.new do |m|
m.name 'User'
m.field :string, :name
m.field :string, :email
m.field :string, :password_digest
end
# Post model
Model.new do |m|
m.name 'Post'
m.field :string, :title
m.field :text, :body
m.field :references, :user_id
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment