Skip to content

Instantly share code, notes, and snippets.

@DerekK19
Created August 26, 2013 00:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DerekK19/6337090 to your computer and use it in GitHub Desktop.
Save DerekK19/6337090 to your computer and use it in GitHub Desktop.
Rails example commands to generate controllers and models
# typically any app would have these controllers
rails generate controller welcome index
# Assume we want a controller for "posts", which would be a group of "post" models
# A post has a title whcih is a string and content, which is a text
rails generate controller posts
rails generate model Post title:string content:text
# Assume we want a controller for "comments" which would be a group of "comment" models
# A comment has a commenter, which is a string, a body which is a text and a post, which is a reference (to a post)
rails generate controller comments
rails generate model Comment commenter:string body:text post:references
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment