我是相当新的Rails和ActiveAdmin。添加模型管理到主动管理 - 的Rails 3
我想有像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
我不知道,我究竟做错了什么?
任何想法?
嘿检查这个http://railscasts.com/episodes/284-active-admin – Arvind
真棒@Arv书签,非常感谢! – NeoVe