activeadmin 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activeadmin might be problematic. Click here for more details.
- data/.travis.yml +1 -1
- data/CHANGELOG.md +92 -1
- data/CONTRIBUTING.md +3 -3
- data/Gemfile +6 -5
- data/README.rdoc +6 -1
- data/Rakefile +2 -2
- data/app/assets/stylesheets/active_admin/_forms.css.scss +13 -2
- data/app/assets/stylesheets/active_admin/components/_comments.css.scss +1 -0
- data/app/assets/stylesheets/active_admin/components/_table_tools.css.scss +2 -1
- data/app/views/active_admin/resource/index.csv.erb +4 -1
- data/app/views/layouts/active_admin_logged_out.html.erb +3 -3
- data/docs/0-installation.md +0 -7
- data/docs/1-general-configuration.md +37 -0
- data/docs/11-decorators.md +48 -0
- data/docs/12-arbre-components.md +145 -0
- data/docs/2-resource-customization.md +23 -6
- data/docs/3-index-pages.md +5 -0
- data/docs/4-csv-format.md +11 -2
- data/docs/8-custom-actions.md +2 -2
- data/features/breadcrumb.feature +27 -0
- data/features/decorators.feature +41 -0
- data/features/i18n.feature +7 -0
- data/features/index/format_as_csv.feature +40 -3
- data/features/index/index_as_table.feature +6 -6
- data/features/step_definitions/format_steps.rb +6 -1
- data/lib/active_admin.rb +1 -1
- data/lib/active_admin/application.rb +15 -7
- data/lib/active_admin/comments/comment.rb +4 -2
- data/lib/active_admin/csv_builder.rb +2 -1
- data/lib/active_admin/devise.rb +1 -0
- data/lib/active_admin/dsl.rb +25 -0
- data/lib/active_admin/filters/dsl.rb +9 -0
- data/lib/active_admin/filters/forms.rb +2 -0
- data/lib/active_admin/filters/resource_extension.rb +32 -2
- data/lib/active_admin/form_builder.rb +29 -12
- data/lib/active_admin/inputs.rb +1 -0
- data/lib/active_admin/inputs/filter_boolean_input.rb +40 -0
- data/lib/active_admin/inputs/filter_select_input.rb +5 -1
- data/lib/active_admin/locales/bg.yml +1 -0
- data/lib/active_admin/locales/ca.yml +1 -0
- data/lib/active_admin/locales/cs.yml +9 -1
- data/lib/active_admin/locales/da.yml +1 -0
- data/lib/active_admin/locales/de.yml +16 -3
- data/lib/active_admin/locales/en.yml +1 -0
- data/lib/active_admin/locales/es.yml +1 -0
- data/lib/active_admin/locales/fr.yml +5 -1
- data/lib/active_admin/locales/he.yml +3 -2
- data/lib/active_admin/locales/hr.yml +1 -0
- data/lib/active_admin/locales/hu.yml +1 -0
- data/lib/active_admin/locales/it.yml +5 -4
- data/lib/active_admin/locales/ja.yml +12 -12
- data/lib/active_admin/locales/ko.yml +1 -0
- data/lib/active_admin/locales/lt.yml +81 -0
- data/lib/active_admin/locales/lv.yml +2 -1
- data/lib/active_admin/locales/nl.yml +1 -0
- data/lib/active_admin/locales/no-NB.yml +1 -0
- data/lib/active_admin/locales/pl.yml +1 -0
- data/lib/active_admin/locales/pt-BR.yml +3 -2
- data/lib/active_admin/locales/ro.yml +1 -0
- data/lib/active_admin/locales/ru.yml +7 -6
- data/lib/active_admin/locales/sv-SE.yml +1 -0
- data/lib/active_admin/locales/tr.yml +3 -2
- data/lib/active_admin/locales/vi.yml +1 -0
- data/lib/active_admin/locales/zh-CN.yml +1 -0
- data/lib/active_admin/locales/zh-TW.yml +1 -0
- data/lib/active_admin/menu_item.rb +6 -0
- data/lib/active_admin/page.rb +3 -0
- data/lib/active_admin/page_presenter.rb +2 -0
- data/lib/active_admin/resource.rb +12 -1
- data/lib/active_admin/resource/menu.rb +8 -1
- data/lib/active_admin/resource_controller.rb +3 -1
- data/lib/active_admin/resource_controller/collection.rb +1 -1
- data/lib/active_admin/resource_controller/decorators.rb +19 -0
- data/lib/active_admin/resource_dsl.rb +1 -1
- data/lib/active_admin/version.rb +1 -1
- data/lib/active_admin/view_helpers.rb +1 -0
- data/lib/active_admin/view_helpers/breadcrumb_helper.rb +1 -1
- data/lib/active_admin/view_helpers/download_format_links_helper.rb +50 -0
- data/lib/active_admin/view_helpers/fields_for.rb +4 -0
- data/lib/active_admin/view_helpers/flash_helper.rb +13 -0
- data/lib/active_admin/views/components/paginated_collection.rb +2 -11
- data/lib/active_admin/views/components/table_for.rb +21 -27
- data/lib/active_admin/views/footer.rb +3 -1
- data/lib/active_admin/views/index_as_block.rb +1 -1
- data/lib/active_admin/views/index_as_grid.rb +1 -1
- data/lib/active_admin/views/pages/base.rb +3 -3
- data/lib/active_admin/views/pages/index.rb +1 -7
- data/lib/active_admin/views/title_bar.rb +6 -3
- data/lib/generators/active_admin/devise/devise_generator.rb +1 -1
- data/lib/generators/active_admin/install/templates/active_admin.rb.erb +6 -3
- data/lib/generators/active_admin/install/templates/admin_user.rb.erb +1 -1
- data/lib/generators/active_admin/install/templates/dashboard.rb +2 -2
- data/lib/generators/active_admin/install/templates/migrations/2_move_admin_notes_to_comments.rb +2 -1
- data/spec/integration/memory_spec.rb +1 -1
- data/spec/support/rails_template.rb +41 -2
- data/spec/support/rails_template_with_data.rb +2 -1
- data/spec/support/templates/en.yml +2 -0
- data/spec/support/templates/post_decorator.rb +53 -0
- data/spec/unit/application_spec.rb +17 -4
- data/spec/unit/belongs_to_spec.rb +1 -1
- data/spec/unit/config_shared_examples.rb +15 -7
- data/spec/unit/controller_filters_spec.rb +8 -8
- data/spec/unit/csv_builder_spec.rb +10 -0
- data/spec/unit/devise_spec.rb +28 -7
- data/spec/unit/filters/filter_form_builder_spec.rb +24 -0
- data/spec/unit/filters/resource_spec.rb +15 -1
- data/spec/unit/form_builder_spec.rb +4 -0
- data/spec/unit/resource_controller_spec.rb +67 -3
- data/spec/unit/resource_spec.rb +17 -0
- data/spec/unit/view_helpers/download_format_links_helper_spec.rb +39 -0
- data/spec/unit/view_helpers/fields_for_spec.rb +5 -0
- data/spec/unit/views/components/table_for_spec.rb +31 -0
- data/spec/unit/views/pages/layout_spec.rb +1 -1
- data/spec/unit/views/pages/show_spec.rb +21 -0
- data/tasks/parallel_tests.rake +60 -0
- data/tasks/test.rake +2 -1
- metadata +44 -26
@@ -90,7 +90,7 @@ This would ensure that the Post menu item, is at the beginning of the menu.
|
|
90
90
|
|
91
91
|
### Conditionally Showing / Hiding Menu Items
|
92
92
|
|
93
|
-
Menu items can be shown or hidden at runtime using the `:if` option.
|
93
|
+
Menu items can be shown or hidden at runtime using the `:if` option.
|
94
94
|
|
95
95
|
ActiveAdmin.register Post do
|
96
96
|
menu :if => proc{ current_admin_user.can_edit_posts? }
|
@@ -101,8 +101,8 @@ your helpers and current user session information.
|
|
101
101
|
|
102
102
|
## Scoping the queries
|
103
103
|
|
104
|
-
If your administrators have different access levels, you may sometimes want to
|
105
|
-
scope what they have access to. Assuming your User model has the proper
|
104
|
+
If your administrators have different access levels, you may sometimes want to
|
105
|
+
scope what they have access to. Assuming your User model has the proper
|
106
106
|
has_many relationships, you can simply scope the listings and finders like so:
|
107
107
|
|
108
108
|
ActiveAdmin.register Post do
|
@@ -114,8 +114,8 @@ has_many relationships, you can simply scope the listings and finders like so:
|
|
114
114
|
|
115
115
|
That approach limits the posts an admin can access to ```current_user.posts```.
|
116
116
|
|
117
|
-
If you want to do something fancier, for example override a default scope, you can
|
118
|
-
also use :association_method parameter with a normal method on your User model.
|
117
|
+
If you want to do something fancier, for example override a default scope, you can
|
118
|
+
also use :association_method parameter with a normal method on your User model.
|
119
119
|
The only requirement is that your method returns an instance of ActiveRecord::Relation.
|
120
120
|
|
121
121
|
class Ad < ActiveRecord::Base
|
@@ -133,7 +133,7 @@ The only requirement is that your method returns an instance of ActiveRecord::Re
|
|
133
133
|
scope_to :current_user, :association_method => :managed_ads
|
134
134
|
end
|
135
135
|
|
136
|
-
In case you just need to customize the query independently of the current user, you can
|
136
|
+
In case you just need to customize the query independently of the current user, you can
|
137
137
|
override the `scoped_collection` method on the controller:
|
138
138
|
|
139
139
|
ActiveAdmin.register Post do
|
@@ -143,3 +143,20 @@ override the `scoped_collection` method on the controller:
|
|
143
143
|
end
|
144
144
|
end
|
145
145
|
end
|
146
|
+
|
147
|
+
## Customizing resource retrieval
|
148
|
+
|
149
|
+
If you need to completely replace the record retrieving code (e.g., you have a custom
|
150
|
+
`to_param` implementation in your models), override the `resource` method on the controller:
|
151
|
+
|
152
|
+
ActiveAdmin.register Post do
|
153
|
+
controller do
|
154
|
+
def resource
|
155
|
+
Post.where(id: params[:id]).first!
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
In fact, the controllers use [Inherited Resource](https://github.com/josevalim/inherited_resources),
|
161
|
+
so you can use all the
|
162
|
+
[customization features in Inherited Resource](https://github.com/josevalim/inherited_resources#overwriting-defaults).
|
data/docs/3-index-pages.md
CHANGED
@@ -77,6 +77,11 @@ Or to disable for the entire application:
|
|
77
77
|
config.filters = false
|
78
78
|
end
|
79
79
|
|
80
|
+
You can also add a filter and still preserve the default filters:
|
81
|
+
|
82
|
+
preserve_default_filters!
|
83
|
+
filter :author
|
84
|
+
|
80
85
|
## Index default sort order
|
81
86
|
|
82
87
|
You can define the default sort order for index pages:
|
data/docs/4-csv-format.md
CHANGED
@@ -13,11 +13,20 @@ Customizing the CSV format is as simple as customizing the index page.
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
You can
|
16
|
+
You can set custom csv options:
|
17
17
|
|
18
18
|
ActiveAdmin.register Post do
|
19
|
-
csv :
|
19
|
+
csv :options => { :force_quotes => true } do
|
20
20
|
column :title
|
21
21
|
column("Author") { |post| post.author.full_name }
|
22
22
|
end
|
23
23
|
end
|
24
|
+
|
25
|
+
You can set options for the CSV format system-wide:
|
26
|
+
|
27
|
+
# config/initializers/active_admin.rb
|
28
|
+
# Set the CSV builder separator (default is ",")
|
29
|
+
config.csv_column_separator = ';'
|
30
|
+
|
31
|
+
# Set the CSV builder options (default is {})
|
32
|
+
config.csv_options = { :force_quotes => true }
|
data/docs/8-custom-actions.md
CHANGED
@@ -17,7 +17,7 @@ To add a collection action, use the collection_action method:
|
|
17
17
|
|
18
18
|
collection_action :import_csv, :method => :post do
|
19
19
|
# Do some CSV importing work here...
|
20
|
-
redirect_to {:action => :index}, :notice => "CSV imported successfully!"
|
20
|
+
redirect_to {:action => :index}, {:notice => "CSV imported successfully!"}
|
21
21
|
end
|
22
22
|
|
23
23
|
end
|
@@ -37,7 +37,7 @@ following:
|
|
37
37
|
member_action :lock, :method => :put do
|
38
38
|
user = User.find(params[:id])
|
39
39
|
user.lock!
|
40
|
-
redirect_to {:action => :show}, :notice => "Locked!"
|
40
|
+
redirect_to {:action => :show}, {:notice => "Locked!"}
|
41
41
|
end
|
42
42
|
|
43
43
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
Feature: Breadcrumb
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given I am logged in
|
5
|
+
|
6
|
+
Scenario: Default breadcrumb links
|
7
|
+
Given a configuration of:
|
8
|
+
"""
|
9
|
+
ActiveAdmin.register Post do
|
10
|
+
end
|
11
|
+
"""
|
12
|
+
When I am on the new post page
|
13
|
+
Then I should see a link to "Post" in the breadcrumb
|
14
|
+
|
15
|
+
Scenario: Rewritten breadcrumb links
|
16
|
+
Given a configuration of:
|
17
|
+
"""
|
18
|
+
ActiveAdmin.register Post do
|
19
|
+
breadcrumb do
|
20
|
+
[
|
21
|
+
link_to('test', '/admin/test/url')
|
22
|
+
]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
"""
|
26
|
+
When I am on the new post page
|
27
|
+
Then I should see a link to "test" in the breadcrumb
|
@@ -0,0 +1,41 @@
|
|
1
|
+
Feature: Decorators
|
2
|
+
|
3
|
+
Using decorators for index and show sections
|
4
|
+
|
5
|
+
Background:
|
6
|
+
Given a user named "John Doe" exists
|
7
|
+
Given a post with the title "A very unique post" exists
|
8
|
+
And I am logged in
|
9
|
+
|
10
|
+
Scenario: Index page with decorator
|
11
|
+
Given a configuration of:
|
12
|
+
"""
|
13
|
+
ActiveAdmin.register Post do
|
14
|
+
decorate_with PostDecorator
|
15
|
+
|
16
|
+
index do
|
17
|
+
column(:id)
|
18
|
+
column(:title)
|
19
|
+
column(:decorator_method)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
"""
|
23
|
+
When I am on the index page for posts
|
24
|
+
Then I should see "A method only available on the decorator"
|
25
|
+
And I should see "A very unique post"
|
26
|
+
|
27
|
+
Scenario: Show page with decorator
|
28
|
+
Given a configuration of:
|
29
|
+
"""
|
30
|
+
ActiveAdmin.register Post do
|
31
|
+
decorate_with PostDecorator
|
32
|
+
|
33
|
+
show do
|
34
|
+
attributes_table :title, :decorator_method
|
35
|
+
end
|
36
|
+
end
|
37
|
+
"""
|
38
|
+
When I am on the index page for posts
|
39
|
+
And I follow "View"
|
40
|
+
And I should see the attribute "Decorator Method" with "A method only available on the decorator"
|
41
|
+
And I should see the attribute "Title" with "A very unique post"
|
data/features/i18n.feature
CHANGED
@@ -33,3 +33,10 @@ Feature: Internationalization
|
|
33
33
|
And I go to the dashboard
|
34
34
|
Then I should see "Bookstore"
|
35
35
|
Then I should see "Logout"
|
36
|
+
|
37
|
+
Scenario: Overriding translations
|
38
|
+
Given I am logged in
|
39
|
+
And a store named "Hello words" exists
|
40
|
+
When I go to the dashboard
|
41
|
+
When I follow "Bookstores"
|
42
|
+
Then I should see "Download this:"
|
@@ -12,8 +12,8 @@ Feature: Format as CSV
|
|
12
12
|
When I am on the index page for posts
|
13
13
|
And I follow "CSV"
|
14
14
|
And I should download a CSV file for "posts" containing:
|
15
|
-
| Id | Title | Body | Published At | Created At | Updated At |
|
16
|
-
| \d+ | Hello World | | | (.*) | (.*) |
|
15
|
+
| Id | Title | Body | Published At | Starred | Created At | Updated At |
|
16
|
+
| \d+ | Hello World | | | | (.*) | (.*) |
|
17
17
|
|
18
18
|
Scenario: Default with alias
|
19
19
|
Given a configuration of:
|
@@ -24,7 +24,7 @@ Feature: Format as CSV
|
|
24
24
|
When I am on the index page for my_articles
|
25
25
|
And I follow "CSV"
|
26
26
|
And I should download a CSV file for "my-articles" containing:
|
27
|
-
| Id | Title | Body | Published At | Created At | Updated At |
|
27
|
+
| Id | Title | Body | Published At | Starred | Created At | Updated At |
|
28
28
|
|
29
29
|
Scenario: With CSV format customization
|
30
30
|
Given a configuration of:
|
@@ -61,6 +61,24 @@ Feature: Format as CSV
|
|
61
61
|
| Title | Body |
|
62
62
|
| Hello, World | (.*) |
|
63
63
|
|
64
|
+
Scenario: With CSV option customization
|
65
|
+
Given a configuration of:
|
66
|
+
"""
|
67
|
+
ActiveAdmin.register Post do
|
68
|
+
csv :options => {:force_quotes => true} do
|
69
|
+
column :title
|
70
|
+
column :body
|
71
|
+
end
|
72
|
+
end
|
73
|
+
"""
|
74
|
+
And a post with the title "012345" exists
|
75
|
+
When I am on the index page for posts
|
76
|
+
And I follow "CSV"
|
77
|
+
And I should download a CSV file with "," separator for "posts" containing:
|
78
|
+
| Title | Body |
|
79
|
+
| 012345 | (.*) |
|
80
|
+
And the CSV file should contain "012345" in quotes
|
81
|
+
|
64
82
|
Scenario: With default CSV separator option
|
65
83
|
Given a configuration of:
|
66
84
|
"""
|
@@ -79,3 +97,22 @@ Feature: Format as CSV
|
|
79
97
|
| Title | Body |
|
80
98
|
| Hello, World | (.*) |
|
81
99
|
|
100
|
+
Scenario: With default CSV options
|
101
|
+
Given a configuration of:
|
102
|
+
"""
|
103
|
+
ActiveAdmin.application.csv_options = {:force_quotes => true}
|
104
|
+
ActiveAdmin.application.csv_column_separator = ','
|
105
|
+
ActiveAdmin.register Post do
|
106
|
+
csv do
|
107
|
+
column :title
|
108
|
+
column :body
|
109
|
+
end
|
110
|
+
end
|
111
|
+
"""
|
112
|
+
And a post with the title "012345" exists
|
113
|
+
When I am on the index page for posts
|
114
|
+
And I follow "CSV"
|
115
|
+
And I should download a CSV file with "," separator for "posts" containing:
|
116
|
+
| Title | Body |
|
117
|
+
| 012345 | (.*) |
|
118
|
+
And the CSV file should contain "012345" in quotes
|
@@ -113,11 +113,11 @@ Feature: Index as Table
|
|
113
113
|
"""
|
114
114
|
When I am on the index page for posts
|
115
115
|
Then I should see the "posts" table:
|
116
|
-
| [ ] | Id | Title | Body | Published At | Created At | Updated At | |
|
117
|
-
| [ ] | 2 | Bye bye world | Move your... | | /.*/ | /.*/ | ViewEditDelete |
|
118
|
-
| [ ] | 1 | Hello World | From the body | | /.*/ | /.*/ | ViewEditDelete |
|
116
|
+
| [ ] | Id | Title | Body | Published At | Starred | Created At | Updated At | |
|
117
|
+
| [ ] | 2 | Bye bye world | Move your... | | | /.*/ | /.*/ | ViewEditDelete |
|
118
|
+
| [ ] | 1 | Hello World | From the body | | | /.*/ | /.*/ | ViewEditDelete |
|
119
119
|
When I follow "Id"
|
120
120
|
Then I should see the "posts" table:
|
121
|
-
| [ ] | Id | Title | Body | Published At | Created At | Updated At | |
|
122
|
-
| [ ] | 1 | Hello World | From the body | | /.*/ | /.*/ | ViewEditDelete |
|
123
|
-
| [ ] | 2 | Bye bye world | Move your... | | /.*/ | /.*/ | ViewEditDelete |
|
121
|
+
| [ ] | Id | Title | Body | Published At | Starred | Created At | Updated At | |
|
122
|
+
| [ ] | 1 | Hello World | From the body | | | /.*/ | /.*/ | ViewEditDelete |
|
123
|
+
| [ ] | 2 | Bye bye world | Move your... | | | /.*/ | /.*/ | ViewEditDelete |
|
@@ -48,4 +48,9 @@ end
|
|
48
48
|
|
49
49
|
Then /^I should download a CSV file for "([^"]*)" containing:$/ do |resource_name, table|
|
50
50
|
step "I should download a CSV file with \",\" separator for \"#{resource_name}\" containing:", table
|
51
|
-
end
|
51
|
+
end
|
52
|
+
|
53
|
+
Then /^the CSV file should contain "([^"]*)" in quotes$/ do |text|
|
54
|
+
body = page.driver.response.body
|
55
|
+
body.should match(/\"#{text}\"/)
|
56
|
+
end
|
data/lib/active_admin.rb
CHANGED
@@ -53,7 +53,7 @@ module ActiveAdmin
|
|
53
53
|
config.after_initialize do
|
54
54
|
# Add load paths straight to I18n, so engines and application can overwrite it.
|
55
55
|
require 'active_support/i18n'
|
56
|
-
I18n.load_path
|
56
|
+
I18n.load_path.unshift *Dir[File.expand_path('../active_admin/locales/*.yml', __FILE__)]
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
@@ -12,6 +12,11 @@ module ActiveAdmin
|
|
12
12
|
setting name, default
|
13
13
|
end
|
14
14
|
|
15
|
+
def self.deprecated_inheritable_setting(name, default)
|
16
|
+
Namespace.deprecated_setting name, nil
|
17
|
+
deprecated_setting name, default
|
18
|
+
end
|
19
|
+
|
15
20
|
# The default namespace to put controllers and routes inside. Set this
|
16
21
|
# in config/initializers/active_admin.rb using:
|
17
22
|
#
|
@@ -66,8 +71,8 @@ module ActiveAdmin
|
|
66
71
|
# The namespace root.
|
67
72
|
inheritable_setting :root_to, 'dashboard#index'
|
68
73
|
|
69
|
-
# Default CSV
|
70
|
-
inheritable_setting :
|
74
|
+
# Default CSV options
|
75
|
+
inheritable_setting :csv_options, {}
|
71
76
|
|
72
77
|
# Active Admin makes educated guesses when displaying objects, this is
|
73
78
|
# the list of methods it tries calling in order
|
@@ -82,6 +87,9 @@ module ActiveAdmin
|
|
82
87
|
|
83
88
|
# == Deprecated Settings
|
84
89
|
|
90
|
+
# @deprecated Default CSV separator will be removed in 0.6.0. Use `csv_options = { :col_sep => ',' }` instead.
|
91
|
+
deprecated_inheritable_setting :csv_column_separator, ','
|
92
|
+
|
85
93
|
# @deprecated The default sort order for index pages
|
86
94
|
deprecated_setting :default_sort_order, 'id_desc'
|
87
95
|
|
@@ -212,26 +220,26 @@ module ActiveAdmin
|
|
212
220
|
end
|
213
221
|
|
214
222
|
#
|
215
|
-
# Add before, around and after filters to each registered resource.
|
223
|
+
# Add before, around and after filters to each registered resource and pages.
|
216
224
|
#
|
217
225
|
# eg:
|
218
226
|
#
|
219
227
|
# ActiveAdmin.before_filter :authenticate_admin!
|
220
228
|
#
|
221
229
|
def before_filter(*args, &block)
|
222
|
-
|
230
|
+
BaseController.before_filter(*args, &block)
|
223
231
|
end
|
224
232
|
|
225
233
|
def skip_before_filter(*args, &block)
|
226
|
-
|
234
|
+
BaseController.skip_before_filter(*args, &block)
|
227
235
|
end
|
228
236
|
|
229
237
|
def after_filter(*args, &block)
|
230
|
-
|
238
|
+
BaseController.after_filter(*args, &block)
|
231
239
|
end
|
232
240
|
|
233
241
|
def around_filter(*args, &block)
|
234
|
-
|
242
|
+
BaseController.around_filter(*args, &block)
|
235
243
|
end
|
236
244
|
|
237
245
|
# Helper method to add a dashboard section
|
@@ -6,8 +6,6 @@ module ActiveAdmin
|
|
6
6
|
::ActiveRecord::Base.send :include, Kaminari::ActiveRecordExtension
|
7
7
|
|
8
8
|
class Comment < ActiveRecord::Base
|
9
|
-
self.table_name = "active_admin_comments"
|
10
|
-
|
11
9
|
belongs_to :resource, :polymorphic => true
|
12
10
|
belongs_to :author, :polymorphic => true
|
13
11
|
|
@@ -41,6 +39,10 @@ module ActiveAdmin
|
|
41
39
|
columns.select { |i| i.name == "resource_id" }.first.type
|
42
40
|
end
|
43
41
|
|
42
|
+
def self.table_name
|
43
|
+
@table_name ||= ActiveRecord::Migrator.proper_table_name("active_admin_comments")
|
44
|
+
end
|
45
|
+
|
44
46
|
end
|
45
47
|
|
46
48
|
end
|
@@ -25,11 +25,12 @@ module ActiveAdmin
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
attr_reader :columns, :column_separator
|
28
|
+
attr_reader :columns, :column_separator, :options
|
29
29
|
|
30
30
|
def initialize(options={}, &block)
|
31
31
|
@columns = []
|
32
32
|
@column_separator = options.delete(:separator)
|
33
|
+
@options = options.delete(:options)
|
33
34
|
instance_eval &block if block_given?
|
34
35
|
end
|
35
36
|
|
data/lib/active_admin/devise.rb
CHANGED
@@ -34,6 +34,7 @@ module ActiveAdmin
|
|
34
34
|
|
35
35
|
# Redirect to the default namespace on logout
|
36
36
|
def root_path
|
37
|
+
(Rails.configuration.action_controller[:relative_url_root] || '') +
|
37
38
|
if ActiveAdmin.application.default_namespace
|
38
39
|
"/#{ActiveAdmin.application.default_namespace}"
|
39
40
|
else
|
data/lib/active_admin/dsl.rb
CHANGED
@@ -120,9 +120,34 @@ module ActiveAdmin
|
|
120
120
|
def menu(options = {})
|
121
121
|
config.menu(options)
|
122
122
|
end
|
123
|
+
|
124
|
+
# Rewrite breadcrumb links.
|
125
|
+
# Block will be executed inside controller.
|
126
|
+
# Block must return an array if you want to rewrite breadcrumb links.
|
127
|
+
#
|
128
|
+
# Example:
|
129
|
+
# ActiveAdmin.register Post do
|
130
|
+
#
|
131
|
+
# breadcrumb do
|
132
|
+
# [
|
133
|
+
# link_to('my piece', '/my/link/to/piece')
|
134
|
+
# ]
|
135
|
+
# end
|
136
|
+
# end
|
137
|
+
#
|
138
|
+
def breadcrumb(&block)
|
139
|
+
config.breadcrumb = block
|
140
|
+
end
|
123
141
|
|
124
142
|
def sidebar(name, options = {}, &block)
|
125
143
|
config.sidebar_sections << ActiveAdmin::SidebarSection.new(name, options, &block)
|
126
144
|
end
|
145
|
+
|
146
|
+
def decorate_with(decorator_class)
|
147
|
+
# Force storage as a string. This will help us with reloading issues.
|
148
|
+
# Assuming decorator_class.to_s will return the name of the class allows
|
149
|
+
# us to handle a string or a class.
|
150
|
+
config.decorator_class_name = "::#{ decorator_class }"
|
151
|
+
end
|
127
152
|
end
|
128
153
|
end
|