get the data to work with active_yaml

This commit is contained in:
2023-02-08 11:55:44 +02:00
parent 1181dd0bfd
commit b956f5709a
18 changed files with 82 additions and 64 deletions

View File

@ -1,2 +1,2 @@
class Image
class Image < ActiveYaml::Base
end

View File

@ -1,17 +0,0 @@
<%= form_with(model: image) do |form| %>
<% if image.errors.any? %>
<div style="color: red">
<h2><%= pluralize(image.errors.count, "error") %> prohibited this image from being saved:</h2>
<ul>
<% image.errors.each do |error| %>
<li><%= error.full_message %></li>
<% end %>
</ul>
</div>
<% end %>
<div>
<%= form.submit %>
</div>
<% end %>

View File

@ -1,2 +0,0 @@
<div id="<%= dom_id image %>">
</div>

View File

@ -1,10 +0,0 @@
<h1>Editing image</h1>
<%= render "form", image: @image %>
<br>
<div>
<%= link_to "Show this image", @image %> |
<%= link_to "Back to images", images_path %>
</div>

View File

@ -1,14 +0,0 @@
<p style="color: green"><%= notice %></p>
<h1>Images</h1>
<div id="images">
<% @images.each do |image| %>
<%= render image %>
<p>
<%= link_to "Show this image", image %>
</p>
<% end %>
</div>
<%= link_to "New image", new_image_path %>

View File

@ -1,9 +0,0 @@
<h1>New image</h1>
<%= render "form", image: @image %>
<br>
<div>
<%= link_to "Back to images", images_path %>
</div>

View File

@ -1,10 +0,0 @@
<p style="color: green"><%= notice %></p>
<%= render @image %>
<div>
<%= link_to "Edit this image", edit_image_path(@image) %> |
<%= link_to "Back to images", images_path %>
<%= button_to "Destroy this image", @image, method: :delete %>
</div>

View File

@ -1,3 +1,4 @@
Rails.application.routes.draw do
resources :images
root to: "images#show" , id: 1
end

7
test/dummy/images.yml Normal file
View File

@ -0,0 +1,7 @@
- id: 1
name: US
- id: 2
name: Canada
- id: 3
name: Mexico