class method
self.from_node
Ruby on Rails 7.1.6
Since v6.0.6Signature
self.from_node(node)
Extracts the ActionText::Attachable from the attachment HTML node:
person = Person.create! name: "Javan" html = %Q(<action-text-attachment sgid="#{person.attachable_sgid}"></action-text-attachment>) fragment = ActionText::Fragment.wrap(html) attachment_node = fragment.find_all(ActionText::Attachment.tag_name).first ActionText::Attachable.from_node(attachment_node) # => person
Parameters
-
nodereq
Source
# File actiontext/lib/action_text/attachable.rb, line 29
def from_node(node)
if attachable = attachable_from_sgid(node["sgid"])
attachable
elsif attachable = ActionText::Attachables::ContentAttachment.from_node(node)
attachable
elsif attachable = ActionText::Attachables::RemoteImage.from_node(node)
attachable
else
ActionText::Attachables::MissingAttachable.new(node["sgid"])
end
end
Defined in actiontext/lib/action_text/attachable.rb line 29
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionText::Attachable