Skip to content

Commit

Permalink
Merge 7cc1987 into 0af2fdc
Browse files Browse the repository at this point in the history
  • Loading branch information
timoschilling committed Aug 28, 2014
2 parents 0af2fdc + 7cc1987 commit ef56547
Show file tree
Hide file tree
Showing 93 changed files with 371 additions and 367 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -3,6 +3,7 @@
### Major Changes
* Migration from Metasearch to Ransack [#1979][] by [@seanlinsley][]
* Rails 4 support [#2326][] by many people :heart:
* deprecate ActiveAdmin.register, in flavor of ActiveAdmin.register_resource [#3378][] by [@timoschilling][]

### Enhancements
* Make AA ORM-agnostic [#2545][] by [@johnnyshields][]
Expand Down
4 changes: 2 additions & 2 deletions docs/1-general-configuration.md
Expand Up @@ -54,7 +54,7 @@ The default namespace is "admin".

```ruby
# app/admin/posts.rb
ActiveAdmin.register Post do
ActiveAdmin.register_resource Post do
# ...
end
```
Expand Down Expand Up @@ -114,7 +114,7 @@ ActiveAdmin.setup do |config|
end

# For a given resource:
ActiveAdmin.register Post do
ActiveAdmin.register_resource Post do
config.comments = false
end
```
Expand Down
4 changes: 2 additions & 2 deletions docs/11-decorators.md
Expand Up @@ -22,7 +22,7 @@ class PostDecorator < ApplicationDecorator
end

# app/admin/post.rb
ActiveAdmin.register Post do
ActiveAdmin.register_resource Post do
decorate_with PostDecorator

index do
Expand All @@ -40,7 +40,7 @@ If you need ActiveAdmin to decorate the forms, you can pass `decorate: true` to
form block.

```ruby
ActiveAdmin.register Post do
ActiveAdmin.register_resource Post do
decorate_with PostDecorator

form decorate: true do |f|
Expand Down
2 changes: 1 addition & 1 deletion docs/12-arbre-components.md
Expand Up @@ -11,7 +11,7 @@ these elements into the page inside of other Arbre components or resource
controller functions.

```ruby
ActiveAdmin.register Post do
ActiveAdmin.register_resource Post do
show do
panel "Post Details" do
attributes_table_for post do
Expand Down
4 changes: 2 additions & 2 deletions docs/13-authorization-adapter.md
Expand Up @@ -133,7 +133,7 @@ authorized to perform an action on a subject.
Simply use the `#authorized?(action, subject) method to check.

```ruby
ActiveAdmin.register Post do
ActiveAdmin.register_resource Post do

index do
column :title
Expand All @@ -149,7 +149,7 @@ If you are implementing a custom controller action, you can use the
`#authorize!` method to raise an `ActiveAdmin::AccessDenied` exception.

```ruby
ActiveAdmin.register Post do
ActiveAdmin.register_resource Post do

member_action :publish, method: :post do
post = Post.find(params[:id])
Expand Down
60 changes: 30 additions & 30 deletions docs/2-resource-customization.md
Expand Up @@ -9,7 +9,7 @@ The basic command for creating a resource is `rails g active_admin:resource Post
The generator will produce an empty `app/admin/post.rb` file like so:

```ruby
ActiveAdmin.register Post do
ActiveAdmin.register_resource Post do
# everything happens here :D
end
```
Expand All @@ -22,7 +22,7 @@ which moves attribute whitelisting from the model to the controller.
Use the `permit_params` method to define which attributes may be changed:

```ruby
ActiveAdmin.register Post do
ActiveAdmin.register_resource Post do
permit_params :title, :content, :publisher_id
end
```
Expand All @@ -31,7 +31,7 @@ Any form field that sends multiple values (such as a HABTM association, or an ar
needs to pass an empty array to `permit_params`:

```ruby
ActiveAdmin.register Post do
ActiveAdmin.register_resource Post do
permit_params :title, :content, :publisher_id, roles: []
end
```
Expand All @@ -40,7 +40,7 @@ Nested associations in the same form also require an array, but it
needs to be filled with any attributes used.

```ruby
ActiveAdmin.register Post do
ActiveAdmin.register_resource Post do
permit_params :title, :content, :publisher_id,
tags_attributes: [:id, :name, :description, :_destroy]
end
Expand All @@ -54,7 +54,7 @@ end
If you want to dynamically choose which attributes can be set, pass a block:

```ruby
ActiveAdmin.register Post do
ActiveAdmin.register_resource Post do
permit_params do
params = [:title, :content, :publisher_id]
params.push :author_id if current_user.admin?
Expand All @@ -66,7 +66,7 @@ end
The `permit_params` call creates a method called `permitted_params`. You should use this method when overriding `create` or `update` actions:

```ruby
ActiveAdmin.register Post do
ActiveAdmin.register_resource Post do
controller do
def create
# Good
Expand All @@ -87,7 +87,7 @@ end
All CRUD actions are enabled by default. These can be disabled for a given resource:

```ruby
ActiveAdmin.register Post do
ActiveAdmin.register_resource Post do
actions :all, except: [:update, :destroy]
end
```
Expand All @@ -99,7 +99,7 @@ interface will use the name of the class. You can rename the resource by using
the `:as` option.

```ruby
ActiveAdmin.register Post, as: "Article"
ActiveAdmin.register_resource Post, as: "Article"
```

The resource will then be available at `/admin/articles`.
Expand All @@ -110,10 +110,10 @@ We use the `admin` namespace by default, but you can use anything:

```ruby
# Available at /today/posts
ActiveAdmin.register Post, namespace: :today
ActiveAdmin.register_resource Post, namespace: :today

# Available at /posts
ActiveAdmin.register Post, namespace: false
ActiveAdmin.register_resource Post, namespace: false
```

## Customize the Menu
Expand All @@ -122,7 +122,7 @@ The resource will be displayed in the global navigation by default. To disable
the resource from being displayed in the global navigation:

```ruby
ActiveAdmin.register Post do
ActiveAdmin.register_resource Post do
menu false
end
```
Expand All @@ -141,15 +141,15 @@ The menu method accepts a hash with the following options:
To change the name of the label in the menu:

```ruby
ActiveAdmin.register Post do
ActiveAdmin.register_resource Post do
menu label: "My Posts"
end
```

If you want something more dynamic, pass a proc instead:

```ruby
ActiveAdmin.register Post do
ActiveAdmin.register_resource Post do
menu label: proc{ I18n.t "mypost" }
end
```
Expand All @@ -162,7 +162,7 @@ every menu by default has a priority of `10`, the menu is normally alphabetical.
You can easily customize this:

```ruby
ActiveAdmin.register Post do
ActiveAdmin.register_resource Post do
menu priority: 1 # so it's on the very left
end
```
Expand All @@ -171,7 +171,7 @@ end

Menu items can be shown or hidden at runtime using the `:if` option.
```ruby
ActiveAdmin.register Post do
ActiveAdmin.register_resource Post do
menu if: proc{ current_user.can_edit_posts? }
end
```
Expand All @@ -185,7 +185,7 @@ In many cases, a single level navigation will not be enough to manage a large
application. In that case, you can group your menu items under a parent menu item.

```ruby
ActiveAdmin.register Post do
ActiveAdmin.register_resource Post do
menu parent: "Blog"
end
```
Expand All @@ -208,7 +208,7 @@ config.namespace :admin do |admin|
end

# app/admin/post.rb
ActiveAdmin.register Post do
ActiveAdmin.register_resource Post do
menu parent: 'Blog'
end
```
Expand All @@ -227,7 +227,7 @@ config.namespace :admin do |admin|
end

# app/admin/post.rb
ActiveAdmin.register Post do
ActiveAdmin.register_resource Post do
menu parent: 'blog'
end
```
Expand Down Expand Up @@ -261,7 +261,7 @@ scope what they have access to. Assuming your User model has the proper
has_many relationships, you can simply scope the listings and finders like so:

```ruby
ActiveAdmin.register Post do
ActiveAdmin.register_resource Post do
scope_to :current_user # limits the accessible posts to `current_user.posts`

# Or if the association doesn't have the default name:
Expand All @@ -277,7 +277,7 @@ end
You can also conditionally apply the scope:

```ruby
ActiveAdmin.register Post do
ActiveAdmin.register_resource Post do
scope_to :current_user, if: proc{ current_user.limited_access? }
scope_to :current_user, unless: proc{ current_user.admin? }
end
Expand All @@ -288,7 +288,7 @@ end
A common way to increase page performance is to elimate N+1 queries by eager loading associations:

```ruby
ActiveAdmin.register Post do
ActiveAdmin.register_resource Post do
controller do
def scoped_collection
super.includes :author, :categories
Expand All @@ -301,7 +301,7 @@ If you need to completely replace the record retrieving code (e.g., you have a c
`to_param` implementation in your models), override the `resource` method on the controller:

```ruby
ActiveAdmin.register Post do
ActiveAdmin.register_resource Post do
controller do
def find_resource
Post.where(id: params[:id]).first!
Expand All @@ -320,8 +320,8 @@ example a Project may have many Milestones and Tickets. To nest the resource
within another, you can use the `belongs_to` method:

```ruby
ActiveAdmin.register Project
ActiveAdmin.register Ticket do
ActiveAdmin.register_resource Project
ActiveAdmin.register_resource Ticket do
belongs_to :project
end
```
Expand All @@ -335,7 +335,7 @@ To create links to the resource, you can add them to a sidebar (one of the many
possibilities for how you may with to handle your user interface):

```ruby
ActiveAdmin.register Project do
ActiveAdmin.register_resource Project do

sidebar "Project Details", only: [:show, :edit] do
ul do
Expand All @@ -345,11 +345,11 @@ ActiveAdmin.register Project do
end
end

ActiveAdmin.register Ticket do
ActiveAdmin.register_resource Ticket do
belongs_to :project
end

ActiveAdmin.register Milestone do
ActiveAdmin.register_resource Milestone do
belongs_to :project
end
```
Expand All @@ -360,12 +360,12 @@ project. To accomplish this, Active Admin stores the `belongs_to` resources in a
seperate menu which you can use if you so wish. To use:

```ruby
ActiveAdmin.register Ticket do
ActiveAdmin.register_resource Ticket do
belongs_to :project
navigation_menu :project
end

ActiveAdmin.register Milestone do
ActiveAdmin.register_resource Milestone do
belongs_to :project
navigation_menu :project
end
Expand All @@ -379,7 +379,7 @@ You can also defer the menu lookup until runtime so that you can dynamically sho
different menus, say perhaps based on user permissions. For example:

```ruby
ActiveAdmin.register Ticket do
ActiveAdmin.register_resource Ticket do
belongs_to :project
navigation_menu do
authorized?(:manage, SomeResource) ? :project : :restricted_menu
Expand Down
14 changes: 7 additions & 7 deletions docs/3-index-pages.md
Expand Up @@ -68,7 +68,7 @@ filters that are displayed as well as the type of widgets they use.
To display a filter for an attribute, use the `filter` method

```ruby
ActiveAdmin.register Post do
ActiveAdmin.register_resource Post do
filter :title
end
```
Expand Down Expand Up @@ -120,7 +120,7 @@ application.
To disable for a specific resource:

```ruby
ActiveAdmin.register Post do
ActiveAdmin.register_resource Post do
config.filters = false
end
```
Expand Down Expand Up @@ -182,7 +182,7 @@ end
You can define the default sort order for index pages:

```ruby
ActiveAdmin.register Post do
ActiveAdmin.register_resource Post do
config.sort_order = 'name_asc'
end
```
Expand All @@ -192,15 +192,15 @@ end
You can set the number of records per page per resources:

```ruby
ActiveAdmin.register Post do
ActiveAdmin.register_resource Post do
config.per_page = 10
end
```

You can also disable pagination:

```ruby
ActiveAdmin.register Post do
ActiveAdmin.register_resource Post do
config.paginate = false
end
```
Expand All @@ -209,7 +209,7 @@ If you have a very large database, you might want to disable `SELECT COUNT(*)`
queries caused by the pagination info at the bottom of the page:

```ruby
ActiveAdmin.register Post do
ActiveAdmin.register_resource Post do
index pagination_total: false do
# ...
end
Expand All @@ -222,7 +222,7 @@ You can easily remove or customize the download links you want displayed:

```ruby
# Per resource:
ActiveAdmin.register Post do
ActiveAdmin.register_resource Post do

index download_links: false
index download_links: [:pdf]
Expand Down

0 comments on commit ef56547

Please sign in to comment.