我使用Ruby ruby 1.9.2p290和Ruby on Rails 3.2.1时遇到ActiveAdmin的问题.
我使用此Wiki页面为完美运行的AdminUsers设置资源:您的第一个管理资源:AdminUser
之后我想为我的项目模型创建资源.迁移的内容如下所示:
class CreateProjects < ActiveRecord::Migration
def change
create_table :projects do |t|
t.string :name
t.text :description
t.boolean :isactive
t.timestamps
end
end
end
class AddSlugToProjects < ActiveRecord::Migration
def change
add_column :projects, :slug, :string
add_index :projects, :slug
end
end
Run Code Online (Sandbox Code Playgroud)
我的项目模型:
class Project < ActiveRecord::Base
scope :isactive, :conditions => ["isactive = ?",true]
extend FriendlyId
friendly_id :name, use: [:slugged, :history]
attr_accessible :name, :description, :isactive
end
Run Code Online (Sandbox Code Playgroud)
这就是project_controller:
class ProjectsController < ApplicationController
def index
#
# @projects gets filled …Run Code Online (Sandbox Code Playgroud)