Closed ryohakjae114 closed 4 months ago
routesにindexアクションを追加 resources :posts, only: %i[index new create]
resources :posts, only: %i[index new create]
indexアクションを作成し、作成日時が新しい順に全postを代入したインスタンス変数を定義
def index @posts = Post.order(created_at: :desc) end
postsのindex.html.hamlを作成する
viewファイルに短文の一覧を表示する
日付と時間を%Y/%m/%d %H:%M:%Sで表示できるように
config.i18n.default_locale = :ja
ja: time: formats: default: "%Y/%m/%d %H:%M:%S"
ダミーデータを作成する
10.times do Post.create(body: Faker::Lorem.paragraph_by_chars(number: rand(10..140))) end
* もし日本語化できなかったらconfig/applicatio.rbに書き足す ```ruby Faker::Config.locale = :ja
routesにindexアクションを追加
resources :posts, only: %i[index new create]
indexアクションを作成し、作成日時が新しい順に全postを代入したインスタンス変数を定義
postsのindex.html.hamlを作成する
viewファイルに短文の一覧を表示する
日付と時間を%Y/%m/%d %H:%M:%Sで表示できるように
config.i18n.default_locale = :ja
ダミーデータを作成する