안녕하세요 아래 코드를 통해 하나 대신에 여러 사진을 업로드하고 싶습니다.클립 클립/활성 관리로 여러 이미지 업로드
은 내가 active admin
및 paperclip
내가 주변에 인터넷 검색 및 스택 오버플로에 다양한 게시물을 체크 아웃 한 작업이 아니라 미경 때죠 내 클라이언트 요청을 관리하는 방법을 잘 모르겠어요,하지만 난 못 찾았어요 해결책은 아직 없습니다. 어떤 제안이나 도움
이
는product
모델
class Product < ActiveRecord::Base
belongs_to :category
belongs_to :label
has_many :product_items, :dependent => :destroy
extend FriendlyId
friendly_id :title, use: [:slugged, :finders]
validates :title, :description, presence: true
validates :price_usd, :price_eu, numericality: {greater_than_or_equal_to: 0.01}
validates :title, uniqueness: true
has_attached_file :image, styles: { medium: "500x500#", thumb: "100x100#" }
validates_attachment_content_type :image, content_type: /\Aimage\/.*\z/
def self.search(query)
where("title LIKE ? OR description LIKE ?", "%#{query}%", "%#{query}%")
end
end
입니다 .... 좋은 것이는 app/admin/product.rb
ActiveAdmin.register Product do
permit_params :title, :slug, :description, :stock_quantity, :image, :price_usd, :price_eu, :category_id, :label_id
index do
column :title
column :slug
column :category
column :label
column :created_at
column :stock_quantity
column :price_eu, :sortable => :price_eu do |product|
number_to_currency(product.price_eu, :unit => " € " , :precision => 0)
end
column :price_euro, :sortable => :price_usd do |product|
number_to_currency(product.price_usd, :unit => " $ " , :precision => 0)
end
actions
end
form do |f|
f.inputs do
f.input :title
f.input :slug
f.input :description, as: :ckeditor, input_html: { ckeditor: { toolbar: 'Full' } }
f.input :stock_quantity
f.input :image
f.input :price_usd
f.input :price_eu
f.input :category
f.input :label
end
actions
end
end
입니다 그리고 여기 products_controller.rb
class ProductsController < ApplicationController
before_action :set_product, only: [:show, :edit, :update, :destroy]
def show
@meta_title = "Samoli #{@product.title}"
@meta_description = @product.description
end
def search
@product = Product.search(params[:query]).order("created_at DESC")
@categories = Category.joins(:products).where(:products => {:id => @product.map{|x| x.id }}).distinct
end
private
# Use callbacks to share common setup or constraints between actions.
def set_product
@product = Product.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def product_params
params.require(:product).permit(:title, :description, :price_usd, :price_eu, :image, :category_id, :stock_quantity, :label_id, :query, :slug)
end
end
위대한! 고마워요. 오늘 밤 나중에 확인해 볼게요, 어떻게되는지 알려 드리겠습니다. – Slowboy
안녕하세요 @veldtmana, 나는 보석을'gemfile'에 추가했지만'active admin'과 통합하는 방법을 모르거나 적어도 그렇게하는 방법을 찾을 수는 없습니다. 아마 구현을 안내해 주시겠습니까? 감사합니다 – Slowboy
안녕하세요 @ Slowboy, 내가 당신을 위해 무엇인가 함께 빨리 집어 넣을 게요 – veldtmana