Skip to content

Instantly share code, notes, and snippets.

@thebucknerlife
Last active December 1, 2017 17:06
Show Gist options
  • Save thebucknerlife/d8f292e137081fa745e1 to your computer and use it in GitHub Desktop.
Save thebucknerlife/d8f292e137081fa745e1 to your computer and use it in GitHub Desktop.
Rails App Steps

Steps in creating a basic rails app

  1. Define your model(s)
  • What tables should exist in the database?
  • What fields should each table have?
  1. Define your associations
  • What are the relationships between your tables?
  1. Generate models
  2. Create your controllers
  3. Create your views
  • Your forms will go in here
  1. Define your routes
  • Consider using resources
  • Consider using nested resources
  • You can view your routes on your server at localhost:3000/rails/info/routes
  1. Steps for creating validations and displaying errors in the view
  • Add validation to your model
  • For example: validates_presence_of
  1. Within the else statement of your controller (in case it doesn't save)
  • Assign the errors to flash
  • For example flash[:danger] = model_name.errors.full_messages
  1. In your application's layout file (app/views/layout/application.html.erb), display your flash messages
  • For example:

    <% flash.keys.each do |f| %>
      <%= flash[f] %> 
    <% end %> 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment