私はEコマースアプリを開発中です。店長はアクティブな管理者経由で商品をアップロードできます。製品がアップロードされると、active admin
パネルのcategory
とlabel
に割り当てられます。これは、問題が非常にうまくいきます。 ROR Appのアクティブ管理パネルからビューで商品の注文を変更することは可能ですか
各category
の中で最も最近のproduct
views/pages/index.html.erb
上のカテゴリ正面画像として表示され、それが魔法のように動作します。
views/pages/index.html.erb
<% @products.each_slice(3) do |products_group| %>
<div class="row">
<% products_group.each do |category, products| %>
<% products.each_with_index do |product, index| %>
<% if index == 0 %>
<div class="col-lg-4 col-sm-6 col-xs-12 center-block " >
<%= link_to category_path (category), { :method => 'GET' } do %>
<%= image_tag product.image.url(:medium), class: "img-responsive" %>
<% end %>
<div class="caption">
<p class="category-name" ><%= product.category.name %></p>
</div>
<% end %>
<% end %>
</div>
<% end %>
</div>
<% end %>
顧客は、顧客が顧客が選択したカテゴリ内の全製品を閲覧することができますがcategory page
pages/categories/show.html.erb
に取られviews/pages/index.html.erb
の画像リンクの上でクリックする
pages/categories/show.html.erb
<div class="container-fluid">
<div class="row category_top">
<% @products.each do |product| %>
<div class="col-lg-3 col-sm-6 col-xs-12 center-block " >
<%= link_to product_path (product) do %>
<%= image_tag product.image.url(:medium), class: "img-responsive" %>
<% end %>
<div class="product_description">
<h5><%= link_to product.title, product %></h5>
<p><%= social_share_button_tag(product.title) %></p>
</div>
</div>
<% end %>
</div>
</div>
問題がpages/categories/show.html.erb
に店長が一部の製品はお互いの横に表示したいということです。
例:4日前、彼はプロダクト(productA)をアップロードし、プロダクトAの隣に表示したいプロダクト(productB)をアップロードしました。しかし、これらの製品の間には、他の製品が100%あります。
だから私の問題のコンテキストは次のとおりです。どのように店長はproductAとproductBがpages/categories/show.html.erb
ビューで隣同士に座っているようactive admin
パネルに製品を再アレンジすることができますか?私はそれも可能ですか?
p.s.これは、ここで私は、アクティブな管理ここ
に取り組んできたのは初めてapp/admin/admin_user.rb
ActiveAdmin.register AdminUser do
permit_params :email, :password, :password_confirmation
index do
selectable_column
id_column
column :email
column :current_sign_in_at
column :sign_in_count
column :created_at
actions
end
filter :email
filter :current_sign_in_at
filter :sign_in_count
filter :created_at
form do |f|
f.inputs "Admin Details" do
f.input :email
f.input :password
f.input :password_confirmation
end
f.actions
end
end
されている自分自身、私はそれを使用していないcategories_controller.rb
class CategoriesController < ApplicationController
before_action :set_category, only: [:show, :edit, :update, :destroy]
def index
@categories = Category.all
end
def show
@products = @category.products
@images = ["1.jpg", "2.jpg", "3.jpg", "4.jpg", "5.jpg"]
@random_no = rand(5)
@random_image = @images[@random_no]
end
private
# Use callbacks to share common setup or constraints between actions.
def set_category
@category = Category.includes(:products).find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def category_params
params.require(:category).permit(:name, :slug)
end
end
ありがとう私は明日それを見てください – DaudiHell
それは働くようです:) – DaudiHell