Skip to content

Instantly share code, notes, and snippets.

@harrisonmalone
Last active October 27, 2018 03:18
Show Gist options
  • Save harrisonmalone/8712e85a11a37a3e8174673b5a8b3c41 to your computer and use it in GitHub Desktop.
Save harrisonmalone/8712e85a11a37a3e8174673b5a8b3c41 to your computer and use it in GitHub Desktop.

Specs

1 - Model

Generate the Article model through the right rails generator. It should have at least the following columns:

  • title, as a string
  • content, as a text

Don't hesitate to crash test your new model in the rails console:

new_article = Article.new(title: 'The meaning of life', content: "It's 42!")
new_article.valid?  # => should be `true`
new_article.save    # => should not display rollback warnings
Article.last        # => should be the one you just saved

2 - Seed

Add the faker gem to your Gemfile and run bundle install. Use this gem to generate 10 fake articles in db/seeds.rb. When your code is done, you can run:

rails db:seed

3 - Routes, Controller & Views

Generate your controller, and implement all 7 CRUD default actions to list, show, create, update and destroy an article.

You can now directly use the resources shortcut in your routes.

Have a look at the live app to see what it should look like. Try to make the forms look like this with CSS. Create the icons using font awesome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment