Skip to content

Commit 2ce34ca

Browse files
committed
Remove hack to get collection_name in ResourceController.
1 parent d87710d commit 2ce34ca

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

features/index/format_as_csv.feature

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ Feature: Format as CSV
1818
Scenario: Default with alias
1919
Given a configuration of:
2020
"""
21-
ActiveAdmin.register Post, :as => "Article"
21+
ActiveAdmin.register Post, :as => "MyArticle"
2222
"""
23-
When I am on the index page for articles
23+
When I am on the index page for my_articles
2424
And I follow "CSV"
25-
And I should download a CSV file for "articles" containing:
25+
And I should download a CSV file for "my-articles" containing:
2626
| Id | Title | Body | Published At | Created At | Updated At |
2727

2828
Scenario: With CSV format customization

lib/active_admin/resource_controller/actions.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,9 @@ def active_admin_template(template)
7171
end
7272

7373
# Returns a filename for the csv file using the collection_name
74-
# and current date such as 'articles-2011-06-24.csv'.
74+
# and current date such as 'my-articles-2011-06-24.csv'.
7575
def csv_filename
76-
collection_name = collection_path.split('/').last
77-
"#{collection_name}-#{Time.now.strftime("%Y-%m-%d")}.csv"
76+
"#{resource_collection_name.to_s.gsub('_', '-')}-#{Time.now.strftime("%Y-%m-%d")}.csv"
7877
end
7978
end
8079
end

0 commit comments

Comments
 (0)