Skip to content

Add "check_parameters" option to "current_page?"#27549

Merged
rafaelfranca merged 1 commit intorails:masterfrom
mpugach:consider_params_in_current_page
Jan 5, 2017
Merged

Add "check_parameters" option to "current_page?"#27549
rafaelfranca merged 1 commit intorails:masterfrom
mpugach:consider_params_in_current_page

Conversation

@mpugach
Copy link
Copy Markdown

@mpugach mpugach commented Jan 3, 2017

Example:

For http://www.example.com/shop/checkout?order=desc&page=1

current_page?('http://www.example.com/shop/checkout')
# => true

current_page?(
  'http://www.example.com/shop/checkout',
  check_parameters: true
)
# => false

This is needed when http://www.example.com/shop/checkout navigation is also present on the page. Without this option both paths are considered current.

@rails-bot
Copy link
Copy Markdown

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @sgrif (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

This repository is being automatically checked for code quality issues using Code Climate. You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a Pull Request is considered ready to review.

Please see the contribution instructions for more information.

@mpugach mpugach force-pushed the consider_params_in_current_page branch from 1346959 to 7c0d853 Compare January 3, 2017 05:37
@mpugach mpugach changed the title Add strict_params option to current_page? Add "strict_params" option to "current_page?" Jan 3, 2017
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this line is needed? Should not the keyword argument take care of this?

Copy link
Copy Markdown
Author

@mpugach mpugach Jan 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not always

def ololo(options, some_keyword: false)
  puts options.inspect
  puts some_keyword.inspect
end

ololo(action: :index, controller: :some, some_keyword: :tralala)
# {:action=>:index, :controller=>:some, :some_keyword=>:tralala}
# false

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe check_paramters is a better name?

@mpugach mpugach force-pushed the consider_params_in_current_page branch from 7c0d853 to cb4122d Compare January 4, 2017 04:32
@mpugach mpugach force-pushed the consider_params_in_current_page branch from cb4122d to 13352f6 Compare January 4, 2017 04:34
@mpugach mpugach changed the title Add "strict_params" option to "current_page?" Add "check_parameters" option to "current_page?" Jan 4, 2017
@mpugach
Copy link
Copy Markdown
Author

mpugach commented Jan 4, 2017

@rafaelfranca, updated

@rafaelfranca rafaelfranca merged commit 333283e into rails:master Jan 5, 2017
Edouard-chin added a commit to Edouard-chin/rails that referenced this pull request Apr 26, 2017
- `check_parameters` kwargs was added to the `current_page?` method, the implementation was assuming only hashes responds to `delete`. This was causing issues when `current_page?` was called with a Active Model object
- ref rails#27549
- Fixes rails#28846
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants