【发布时间】:2015-08-24 11:59:43
【问题描述】:
我对 Rails 和 ActiveAdmin 还很陌生。
我希望有一个类似于 Django 管理员的界面和我的应用模型,这样我就可以管理产品和其他东西。
到目前为止,我有 admin_users 网址,我可以在其中向我的应用添加或删除管理员用户,这太棒了。
我正在使用 Rails 3,我想知道是否可以在用户之外添加一个新菜单,以便我可以从 dashboard 管理其他模型
我试过rails generate active_admin:resource Product
它会在app/admin/ 上创建一个名为product.rb 的文件,但它不起作用,这是我的Product 模型product.rb
class Product < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable,
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me
belongs_to :category
has_many :line_items
has_many :orders, through: :line_items
validates_presence_of :category_id, :name, :price_cents
attr_accessible :avatar
has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>" }, :default_url => "/images/:style/missing.png"
validates_attachment_content_type :avatar, :content_type => /\Aimage\/.*\Z/
attr_accessor :price
attr_accessible :category_id, :description, :image, :name, :price_cents, :upc_code, :price, :taxable
def price
price_cents/100.0 if price_cents
end
def price= price
self.price_cents = (price.to_f*100).round
end
end
我不知道,我做错了什么?
有什么想法吗?
【问题讨论】:
-
很棒的@Arv书签,非常感谢!
标签: ruby-on-rails ruby django ruby-on-rails-3 activeadmin