1
0

More than 1 year has passed since last update.

shionさん主催のコワーキングスペース C作業場さんの勉強会がいい感じだったので、Rails Pluginを「リリースした話」

Last updated at Posted at 2022-03-26

この記事は

データベースを使って手っ取り早く(計算量は考えずに)ツリーダイアグラムを描きたいんだよって人向けに作ったRails Pluginを紹介する記事です。

ActsAsTreeDiagram.gif

やりたかったこと

mermaidもいいけど出来るだけ手作業はしたくなかったので

前提

  • Rails
  • ActAsTree

やり方

# Gemfile
gem "acts_as_tree_diagram"
// app/assets/application.scss
@import 'acts_as_tree_diagram'
# model
class Animal < ApplicationRecord
	extend ActsAsTreeDiagram::ViewDiagram
	acts_as_tree order: 'name'
end
<div id="act_as_tree_diagram">
    <ul class="tree">
        <li>
            <code>
                <%= link_to Animal.find(1).name, animals_path(Animal.find(1)) %>
            </code>
            <ul>
                <%= Animal.diagram_molecules_tag(where: { id: 1 }, path: animals_path).html_safe %>
            </ul>
        </li>
    </ul>
</div>

最後までお読みいただきありがとうございます。
もし、気に入っていただける内容ありましたら、「いいね」や「シェア」していただけるととても嬉しいです。
今後の活動の大きな励みになります!

参加した勉強会

[新宿御苑前]がやがやと勉強する会(テーマ自由、初心者歓迎!) - connpass

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0