- Define your model(s)
- What tables should exist in the database?
- What fields should each table have?
- Define your associations
- What are the relationships between your tables?
- Generate models
- Create your controllers
- Create your views
- Your forms will go in here
- Define your routes
- Consider using resources
- Consider using nested resources
- You can view your routes on your server at
localhost:3000/rails/info/routes
- Steps for creating validations and displaying errors in the view
- Add validation to your model
- For example:
validates_presence_of
- 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
- 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 %>