Neo*_*oVe 6 ruby django ruby-on-rails ruby-on-rails-3 activeadmin
我是Rails和ActiveAdmin的新手.
我希望有一个类似Django管理员的界面,我的应用程序模型,所以我可以管理产品和其他东西.
到目前为止,我有admin_users我可以在我的应用程序中添加或删除管理员用户的URL,这太棒了.
我正在使用Rails 3,我想知道我是否可以添加除用户之外的新菜单,以便我可以管理其他模型 dashboard
我试过了 rails generate active_admin:resource Product
它创建一个名为product.rbon 的文件,app/admin/但它不起作用,这是我的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
Run Code Online (Sandbox Code Playgroud)
我不知道,我做错了什么?
有任何想法吗?
要注册您的Product模型,请运行:
rails generate active_admin:resource Product
Run Code Online (Sandbox Code Playgroud)
这将创建一个app/admin/product.rb用于配置资源的文件.刷新Web浏览器以查看界面.
请查看Active Admin Documentation以获取更多详细信息.
| 归档时间: |
|
| 查看次数: |
4555 次 |
| 最近记录: |