Class: Spina::Admin::EmbedsController

Inherits:
AdminController
  • Object
show all
Defined in:
app/controllers/spina/admin/embeds_controller.rb

Instance Method Summary collapse

Methods inherited from AdminController

#current_admin_path

Instance Method Details

#createObject



8
9
10
11
12
13
14
15
16
# File 'app/controllers/spina/admin/embeds_controller.rb', line 8

def create
  @embeddable = Spina::Embeds.constantize(embed_type).new(embed_params)

  if @embeddable.valid?
    render turbo_stream: turbo_stream.update(:trix_attachment_html, @embeddable.to_trix_attachment)
  else
    render :new, status: :unprocessable_entity
  end
end

#newObject



4
5
6
# File 'app/controllers/spina/admin/embeds_controller.rb', line 4

def new
  @embeddable = (Spina::Embeds.constantize(embed_type) || embeddables.first).new
end