Home

Awesome

Block Editor for Ruby on Rails - Sample

This is a very basic sample host application for the Block Editor Ruby on Rails gem

It was created by following these steps;

rails new block_editor_sample
rails generate scaffold Post title:string
// Gemfile
gem 'block_editor'
rails block_editor:install:migrations
rails db:migrate
class Post < ApplicationRecord
  include BlockEditor::Listable
end
  <%= form.fields_for :active_block_list do |block_list| %>
    <%= BlockEditor::Instance.render(block_list) %>
  <% end %>

Updated trusted post parameters and specifically set the listable within the PostsController;

  # Only allow a list of trusted parameters through.
  def post_params
    params.require(:post).permit(:title, active_block_list_attributes: [ :id, :content ])
  end
@post.active_block_list.listable = @post
  <%= javascript_pack_tag 'block_editor/application', 'data-turbolinks-track': 'reload', webpacker: 'BlockEditor' %>
  <%= stylesheet_pack_tag 'block_editor/application', 'data-turbolinks-track': 'reload', webpacker: 'BlockEditor' %>
yarn add bootstrap