Gem 继续 active_admin 的问题

xiaoniuniu · 2013年08月31日 · 2357 次阅读

目前想借用 active_admin 的这个 gem 实现后台控制,能在后台上传产品信息和产品对应的图片。 product 和 picture 是 association 的关系 app/admin/product.rb的代码如下(我在admin中没有写picture.rb,可以吗?)

ActiveAdmin.register Product do
  config.per_page = 10

  # Create sections on the index screen
  scope :all, :default => true
  # Filterable attributes on the index screen
  filter :title
  filter :price
  filter :pictures #这里感觉有点问题
  filter :categroy_id
  filter :created_at
  filter :updated_at

  index do
    column :id
    column :title
    column :category_id
    column :pictures
    column "Created At", :created_at
    column "Updated At", :updated_at
    column "Price", :sortable => :price do |product|
      number_to_currency product.price
    end

    default_actions
  end



  form do |f|
    f.inputs "Details of Product" do
      f.input :title
      f.input :price
      f.input :description
      f.input :category_id
    end

    f.has_many :pictures do |picture|
      picture.inputs "Pictures of Product" do
      picture.input :picname
      picture.input :image
      end

  end

    f.actions
  end


  ActiveAdmin.setup do |config|
    # Want PDF added to default download links
    config.download_links = [:csv, :xml, :json, :pdf]
  end


end

在后台页面中,能新增和编辑产品信息(product 中的一些属性),也可以上传照片(picture 中的一些属性)。但是最终照片没有保存到数据库内。这是为什么呢?求大牛们指教~

暂无回复。
需要 登录 后方可回复, 如果你还没有账号请 注册新账号