get the data to work with active_yaml
This commit is contained in:
parent
1181dd0bfd
commit
b956f5709a
3
Gemfile
3
Gemfile
@ -7,8 +7,9 @@ gemspec
|
|||||||
gem "rails"
|
gem "rails"
|
||||||
gem "sprockets-rails"
|
gem "sprockets-rails"
|
||||||
gem "puma" , "5.6.5"
|
gem "puma" , "5.6.5"
|
||||||
|
gem "haml-rails"
|
||||||
gem "sqlite3"
|
gem "sqlite3"
|
||||||
|
gem "active_hash"
|
||||||
|
|
||||||
# Start debugger with binding.b [https://github.com/ruby/debug]
|
# Start debugger with binding.b [https://github.com/ruby/debug]
|
||||||
# gem "debug", ">= 1.0.0"
|
# gem "debug", ">= 1.0.0"
|
||||||
|
14
Gemfile.lock
14
Gemfile.lock
@ -53,6 +53,8 @@ GEM
|
|||||||
erubi (~> 1.4)
|
erubi (~> 1.4)
|
||||||
rails-dom-testing (~> 2.0)
|
rails-dom-testing (~> 2.0)
|
||||||
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
||||||
|
active_hash (3.1.1)
|
||||||
|
activesupport (>= 5.0.0)
|
||||||
activejob (7.0.4.2)
|
activejob (7.0.4.2)
|
||||||
activesupport (= 7.0.4.2)
|
activesupport (= 7.0.4.2)
|
||||||
globalid (>= 0.3.6)
|
globalid (>= 0.3.6)
|
||||||
@ -81,6 +83,15 @@ GEM
|
|||||||
erubi (1.12.0)
|
erubi (1.12.0)
|
||||||
globalid (1.1.0)
|
globalid (1.1.0)
|
||||||
activesupport (>= 5.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)
|
i18n (1.12.0)
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
loofah (2.19.1)
|
loofah (2.19.1)
|
||||||
@ -166,6 +177,7 @@ GEM
|
|||||||
activesupport (>= 5.2)
|
activesupport (>= 5.2)
|
||||||
sprockets (>= 3.0.0)
|
sprockets (>= 3.0.0)
|
||||||
sqlite3 (1.6.0-x86_64-linux)
|
sqlite3 (1.6.0-x86_64-linux)
|
||||||
|
temple (0.10.0)
|
||||||
thor (1.2.1)
|
thor (1.2.1)
|
||||||
tilt (2.0.11)
|
tilt (2.0.11)
|
||||||
timeout (0.3.1)
|
timeout (0.3.1)
|
||||||
@ -180,6 +192,8 @@ PLATFORMS
|
|||||||
x86_64-linux
|
x86_64-linux
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
|
active_hash
|
||||||
|
haml-rails
|
||||||
puma (= 5.6.5)
|
puma (= 5.6.5)
|
||||||
rails
|
rails
|
||||||
sprockets-rails
|
sprockets-rails
|
||||||
|
1
app/assets/config/manifest.js
Normal file
1
app/assets/config/manifest.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
//= link_directory ../javascript .js
|
@ -1 +1,2 @@
|
|||||||
//= link_directory ../stylesheets/vue_r .css
|
//= link_directory ../stylesheets/vue_r .css
|
||||||
|
//= link_directory ../../javascript .js
|
||||||
|
12
app/assets/javascript/application.js.rb
Normal file
12
app/assets/javascript/application.js.rb
Normal 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
|
0
app/views/layouts/application.html.erb
Normal file
0
app/views/layouts/application.html.erb
Normal file
22
config/initializers/opal.rb
Normal file
22
config/initializers/opal.rb
Normal 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
|
19
lib/opal/rails/haml_filter.rb
Normal file
19
lib/opal/rails/haml_filter.rb
Normal 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
|
@ -1,3 +1,5 @@
|
|||||||
|
require "opal-rails"
|
||||||
|
|
||||||
module VueR
|
module VueR
|
||||||
class Engine < ::Rails::Engine
|
class Engine < ::Rails::Engine
|
||||||
isolate_namespace VueR
|
isolate_namespace VueR
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
class Image
|
class Image < ActiveYaml::Base
|
||||||
end
|
end
|
||||||
|
@ -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 %>
|
|
@ -1,2 +0,0 @@
|
|||||||
<div id="<%= dom_id image %>">
|
|
||||||
</div>
|
|
@ -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>
|
|
@ -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 %>
|
|
@ -1,9 +0,0 @@
|
|||||||
<h1>New image</h1>
|
|
||||||
|
|
||||||
<%= render "form", image: @image %>
|
|
||||||
|
|
||||||
<br>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<%= link_to "Back to images", images_path %>
|
|
||||||
</div>
|
|
@ -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>
|
|
@ -1,3 +1,4 @@
|
|||||||
Rails.application.routes.draw do
|
Rails.application.routes.draw do
|
||||||
resources :images
|
resources :images
|
||||||
|
root to: "images#show" , id: 1
|
||||||
end
|
end
|
||||||
|
7
test/dummy/images.yml
Normal file
7
test/dummy/images.yml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
- id: 1
|
||||||
|
name: US
|
||||||
|
- id: 2
|
||||||
|
name: Canada
|
||||||
|
- id: 3
|
||||||
|
name: Mexico
|
||||||
|
|
Loading…
Reference in New Issue
Block a user