get the data to work with active_yaml

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

View File

@ -7,8 +7,9 @@ gemspec
gem "rails"
gem "sprockets-rails"
gem "puma" , "5.6.5"
gem "haml-rails"
gem "sqlite3"
gem "active_hash"
# Start debugger with binding.b [https://github.com/ruby/debug]
# gem "debug", ">= 1.0.0"

View File

@ -53,6 +53,8 @@ GEM
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
active_hash (3.1.1)
activesupport (>= 5.0.0)
activejob (7.0.4.2)
activesupport (= 7.0.4.2)
globalid (>= 0.3.6)
@ -81,6 +83,15 @@ GEM
erubi (1.12.0)
globalid (1.1.0)
activesupport (>= 5.0)
haml (6.1.1)
temple (>= 0.8.2)
thor
tilt
haml-rails (2.1.0)
actionpack (>= 5.1)
activesupport (>= 5.1)
haml (>= 4.0.6)
railties (>= 5.1)
i18n (1.12.0)
concurrent-ruby (~> 1.0)
loofah (2.19.1)
@ -166,6 +177,7 @@ GEM
activesupport (>= 5.2)
sprockets (>= 3.0.0)
sqlite3 (1.6.0-x86_64-linux)
temple (0.10.0)
thor (1.2.1)
tilt (2.0.11)
timeout (0.3.1)
@ -180,6 +192,8 @@ PLATFORMS
x86_64-linux
DEPENDENCIES
active_hash
haml-rails
puma (= 5.6.5)
rails
sprockets-rails

View File

@ -0,0 +1 @@
//= link_directory ../javascript .js

View File

@ -1 +1,2 @@
//= link_directory ../stylesheets/vue_r .css
//= link_directory ../../javascript .js

View File

@ -0,0 +1,12 @@
require "opal"
# Uncomment the following to print out you're hello-world with Opal:
#
# puts "hello world!"
#
# The following will append a hello-world to your <body> element:
#
# require "native"
# $$[:document].addEventListener :DOMContentLoaded do
# $$[:document][:body][:innerHTML] += '<h2>Hello World!</h2>'
# end

View File

View File

@ -0,0 +1,22 @@
# Check out the full list of the available configuration options at
# https://github.com/opal/opal/blob/master/lib/opal/config.rb
Rails.application.configure do
# We suggest keeping the configuration above as default for all environments,
# disabling some of them might slightly reduce the bundle size or reduce performance
# by degrading some ruby features.
config.opal.method_missing_enabled = true
config.opal.const_missing_enabled = true
config.opal.arity_check_enabled = true
config.opal.freezing_stubs_enabled = true
config.opal.dynamic_require_severity = :ignore
# To enable passing assigns from the controller to the opal template handler
# change the following configuration to one of these values:
#
# - true # both locals and instance variables
# - :locals # only locals
# - :ivars # only instance variables
#
config.opal.assigns_in_templates = false
end

View File

@ -0,0 +1,19 @@
require "haml"
require "haml/filters"
require "haml/filters/base"
module Haml
class Filters
class Opal < Base
def compile(node)
temple = [:multi]
temple << [:static, "<script type='text/javascript'>\n"]
temple << [:static, ::Opal.compile(node.value[:text]) ]
temple << [:static, "\n</script>"]
temple
end
end
end
end
Haml::Filters.registered[:opal] ||= Haml::Filters::Opal

View File

@ -1,3 +1,5 @@
require "opal-rails"
module VueR
class Engine < ::Rails::Engine
isolate_namespace VueR

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