-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate the Article model and add to index view
Add an Article model to match the previously created ArticlesController * Generate the Article model with title:string and body:text attributes. * Run the generated migration to produce the schema.rb file. * Change the default generated fixtures to be less boring * Modify the articles index action and view to query and display a list of articles * Update the ArticlesControllerTest with new functionality Completes Rails Getting Started Guide: * 6 MVC and You * 6.1 Generating a Model * 6.2 Database Migrations * 6.3 Using a Model to Interact with the Database * 6.4 Showing a List of Articles
- Loading branch information
1 parent
a1be17b
commit 08201fe
Showing
8 changed files
with
75 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
class ArticlesController < ApplicationController | ||
def index | ||
@articles = Article.all | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class Article < ApplicationRecord | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
<h1>Hello, Rails! Taxation is theft!</h1> | ||
<h1>Articles</h1> | ||
|
||
<ul> | ||
<% @articles.each do |article| %> | ||
<li> | ||
<%= article.title %> | ||
</li> | ||
<% end %> | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class CreateArticles < ActiveRecord::Migration[7.0] | ||
def change | ||
create_table :articles do |t| | ||
t.string :title | ||
t.text :body | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html | ||
|
||
nerd: | ||
title: Check out NerdDice | ||
body: | | ||
These videos take you end-to-end through a project that creates a ruby gem. | ||
(The subject matter of polyhedral dice was chosen because Mike\'s a giant nerd.) | ||
The series covers a number of programming concepts that will help you be a better | ||
software developer, particularly in Ruby. | ||
why: | ||
title: Why Stateless Code | ||
body: | | ||
Inspired by Simon Sinek\'s brilliant video Start with Why, these videos explain the | ||
North Star of Stateless Code. What gets us out of bed in the morning and motivates | ||
us to keep producing videos? Why do we do what we do? What is the dream for this | ||
organization? Start at the center of the Golden Circle and communicate outward rather | ||
than on the outside and communicating inward. Are we just being lazy video editors by | ||
leaving the mistakes in our videos? Why the Jesus is Lord in the footer and the | ||
in-your-face anarchy symbol in the branding? These videos are here to remind ourselves | ||
of our promise to you. Taking the time to stop and think about the Why will help you | ||
prioritize and avoid mission creep. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require "test_helper" | ||
|
||
class ArticleTest < ActiveSupport::TestCase | ||
# test "the truth" do | ||
# assert true | ||
# end | ||
end |