Last active
August 29, 2015 14:03
-
-
Save nbashaw/0adf9746ba9244ce5f19 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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