Skip to content
A simple blog engine skeleton app I made to teach some colleagues Rails
Ruby JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
app
config
db
doc
public
script
test
.gitignore
README.md
Rakefile

README.md

Blog

This is a simple blog engine I created to teach some colleagues the basics of Rails.

These are some of the commands I used to create and scaffold the app:

Create the blog project and use MySQL as the database engine

rails -d mysql blog

Change into your newly created blog project directory:

cd blog

Generate a scaffold for posts, which will need a title, content and a publish flag:

script/generate scaffold Post title:string content:text publish:boolean

Create your database:

rake db:create

Run the migration that was created by the scaffold. This will create the posts table:

rake db:migrate

Start the server:

ruby script/server

Delete the default index.html page:

rm public/index.html

We decided the posts table needed an intro field. Generate a migration to create this:

script/generate migration add_intro_to_posts intro:text

Run the migration you just created. This will alter the table in the database and add the column:

rake db:migrate

We decided we wanted each post to have a number of comments, so we scaffolded this:

script/generate scaffold comment comment:text commenter:string post_id:integer

Again the database needs to be migrated to run the migration generated above:

rake db:migrate

Something went wrong with that request. Please try again.