-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
View helper methods #5493
base: main
Are you sure you want to change the base?
View helper methods #5493
Conversation
class ViewsHelperMethodsTest < Devise::IntegrationTest | ||
|
||
test 'Action View includes Devise::Views::Helpers' do | ||
assert_includes ActionView.ancestors, Devise::Views::Helpers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert_includes ActionView.ancestors, Devise::Views::Helpers | |
assert_includes ActionView.ancestors, Devise::Views::Helpers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we get this pulled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the review. Could we get this pull request submitted?
If/Else conditional statements based on a users session status are relatively common at the controller and view level of applications. These conditional statements are repetitive, accumulate quickly and make our code bulky . Great programs are DRY and this pull request seeks to DRY up our code by creating helper methods that abstract if/else conditionals into methods where a block is called based on a resources sign_in/out state.
Examples:
View ->
user_signed_out do <%= link_to "Sign In", new_user_session_path %> end
Controller ->
def some_action; admin_signed_in { render @posts }; admin_signed_out { redirect_to root_path }; end