Skip to content

Commit

Permalink
Fix deleting an EssenceNode from a content (AlchemyCMS#1834)
Browse files Browse the repository at this point in the history
We can leverage Rails' functionality here.
  • Loading branch information
mamhoff authored May 18, 2020
1 parent 3e4d476 commit 6a08040
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
13 changes: 0 additions & 13 deletions app/models/alchemy/essence_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

module Alchemy
class EssenceNode < BaseRecord
NODE_ID = /\A\d+\z/

acts_as_essence(
ingredient_column: :node,
preview_text_column: :node_name,
Expand All @@ -16,16 +14,5 @@ class EssenceNode < BaseRecord
)

delegate :name, to: :node, prefix: true, allow_nil: true

def ingredient=(node)
case node
when NODE_ID
self.node = Alchemy::Node.new(id: node)
when Alchemy::Node
self.node = node
else
super
end
end
end
end
2 changes: 1 addition & 1 deletion app/views/alchemy/essences/_essence_node_editor.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
data: essence_node_editor.data_attributes do %>
<%= content_label(essence_node_editor) %>
<%= text_field_tag(
essence_node_editor.form_field_name,
essence_node_editor.form_field_name("node_id"),
essence_node_editor.essence.node_id,
id: essence_node_editor.form_field_id,
class: 'alchemy_selectbox full_width'
Expand Down

0 comments on commit 6a08040

Please sign in to comment.