adding stories, scaffold

This commit is contained in:
2023-01-11 18:48:06 +02:00
parent 10686d1f5e
commit 23a2254d2e
18 changed files with 289 additions and 27 deletions

View File

@ -0,0 +1,22 @@
= form_for @story do |f|
- if @story.errors.any?
#error_explanation
%h2= "#{pluralize(@story.errors.count, "error")} prohibited this story from being saved:"
%ul
- @story.errors.full_messages.each do |message|
%li= message
.field
= f.label :picture
= f.text_field :picture
.field
= f.label :header
= f.text_field :header
.field
= f.label :text
= f.text_area :text
.field
= f.label :happened
= f.date_field :happened
.actions
= f.submit 'Save'

View File

@ -0,0 +1,7 @@
%h1 Editing story
= render 'form'
= link_to 'Show', @story
\|
= link_to 'Back', stories_path

View File

@ -0,0 +1,27 @@
%h1 Listing stories
%table
%thead
%tr
%th Picture
%th Header
%th Text
%th Happened
%th
%th
%th
%tbody
- @stories.each do |story|
%tr
%td= story.picture
%td= story.header
%td= story.text
%td= story.happened
%td= link_to 'Show', story
%td= link_to 'Edit', edit_story_path(story)
%td= link_to 'Destroy', story, method: :delete, data: { confirm: 'Are you sure?' }
%br
= link_to 'New Story', new_story_path

View File

@ -0,0 +1,5 @@
%h1 New story
= render 'form'
= link_to 'Back', stories_path

View File

@ -0,0 +1,18 @@
%p#notice= notice
%p
%b Picture:
= @story.picture
%p
%b Header:
= @story.header
%p
%b Text:
= @story.text
%p
%b Happened:
= @story.happened
= link_to 'Edit', edit_story_path(@story)
\|
= link_to 'Back', stories_path