Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix CSV responses when index overriding with the call alias method#8031

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
megos wants to merge2 commits intoactiveadmin:master
base:master
Choose a base branch
Loading
frommegos:fix-csv-responses-when-overriding-index

Conversation

@megos
Copy link

CSV responses are implemented by overriding the index as below.

defindex
superdo |format|
format.csv{stream_csv}
yield(format)ifblock_given?
end
end

If a user overrides the index using the alias method instead of the super, this implementation is ignored and CSV responses are not working.

controllerdodefindexindex!do |format|# Cause "No renderer defined for format: csv"      ...endendend

I add an alias method to make this implementation work anytime.

@megosmegosforce-pushed thefix-csv-responses-when-overriding-index branch from0e3da46 to23be363CompareJuly 27, 2023 00:07
@javierjuliojavierjulioforce-pushed thefix-csv-responses-when-overriding-index branch from23be363 to0da137bCompareAugust 12, 2023 17:10
@mgrunbergmgrunbergforce-pushed thefix-csv-responses-when-overriding-index branch from2b5cee9 to6775587CompareSeptember 26, 2024 21:42
@codecov
Copy link

codecovbot commentedSep 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.11%. Comparing base(3b54bde) to head(6775587).

Additional details and impacted files
@@           Coverage Diff           @@##           master    #8031   +/-   ##=======================================  Coverage   99.11%   99.11%           =======================================  Files         141      141             Lines        4069     4070    +1     =======================================+ Hits         4033     4034    +1  Misses         36       36

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report?Share it here.

@mgrunberg
Copy link
Contributor

@javierjulio this LGTM. What do you think?

@javierjulio
Copy link
Member

@mgrunberg not quite. It's why I held off but left this here as I'd like to see it resolved. I'm just not sure what the solution should be. I encountered this too the year before and resolved by callingsuper instead ofindex! inside theindex action I had overridden. The following is the case I ran into:

controller do  def index    params[:some_flag] = "blah"-   index!+   super  endend

This is puzzling because I'm not sure why we are getting a new action method if InheritedResources would be defining this alias anyway since the Base applies the Actions module. Can you check if the controller has protected methods forshow!,create!, etc.? I realized while responding, that this PR is setting a public alias but InheritedResources declares them as protected. Perhaps that would suffice here as I do recall one concern I had was the unexpected assertion change in the resource_controller_spec.rb file.

I'd like to see tests that have a custom index action that does something, e.g. set a param, before callingindex! where a request is made for bothhtml andcsv to confirm it works as expected.

@mgrunberg
Copy link
Contributor

@javierjulio thanks for the feedback. I need some time to think about your comment. I'll come back to this in a few days. I don't discard even copy this PR as an "in repo".

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@javierjuliojavierjulioAwaiting requested review from javierjulio

1 more reviewer

@Jcpayvoice23Jcpayvoice23Jcpayvoice23 approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@megos@mgrunberg@javierjulio@Jcpayvoice23

[8]ページ先頭

©2009-2025 Movatter.jp