Class: Blog::Admin::PostProductsController

Inherits:
Admin::BaseController
  • Object
show all
Defined in:
app/controllers/blog/admin/post_products_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



5
6
7
8
9
10
# File 'app/controllers/blog/admin/post_products_controller.rb', line 5

def create
  position = @post.products.count
  @product = Variant.find(params[:variant_id]).product
  PostProduct.create(:post_id => @post.id, :product_id => @product.id, :position => position)
  render :partial => "admin/blog/post_products/related_products_table", :locals => { :post => @post }, :layout => false 
end

#destroyObject



12
13
14
15
16
17
# File 'app/controllers/blog/admin/post_products_controller.rb', line 12

def destroy
  @related = PostProduct.find(params[:id])
  if @related.destroy
    render_js_for_destroy
  end
end