Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Wallaby - A Very Rails Way Admin Interface

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on. →

Wallaby - A Very Rails Way Admin Interface

Avatar for Tian Chen

Tian Chen

April 10, 2018

Other Decks in Technology

Transcript

  1. “Can you do a function to allow user to upload

    an image and insert its link into the wysiwyg content just like what GitHub does?“
  2. # app/models/product.rb class Product < ActiveRecord::Base has_one :picture, as: :imageable

    has_many :order_items, class_name: Order::Item.name has_many :orders, through: :order_items belongs_to :category has_and_belongs_to_many :tags end
  3. # app/decorators/product_decorator.rb class ProductDecorator < Wallaby::ResourceDecorator self.show_fields[:preview] = { type:

    'markdown', label: 'preview' } self.show_field_names = %w( preview orders ) def preview "# #{name} - #{sku}\n#{description}" end end
  4. # app/controllers/admin/products_controller module Admin class ProductsController < Wallaby::ResourcesController def self.model_class;

    Product; end def show flash[:warning] ||= "Product import will happen after business hours tonight." super end end end