Opt-in to Current fully #297
Reference in New Issue
Block a user
Delete Branch "current"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
As I floated in #289, this moves towards using
Currentmore fully, and replacing the helper methods likecurrent_userandcurrent_family.To me,
Currentfeels like the more Rails-y way of doing things, andcurrent_*style helpers feel more like the Devise way of doing things. Right now we're sitting half-in half-out of both (especially considering we use a before_action calledauthenticate_user!).Current.familyto the current user's familyCurrentdocs to set the user or redirect away in the one methodIt might even be worth considering dropping
authenticate_userto justauthenticatebut that's neither here nor there. I do think this PR is important because it makes access to the current user/family consistent.Love this.
@@ -19,3 +19,3 @@def create@account = Account.new(account_params.merge(family: current_family))@account = Account.new(account_params.merge(family: Current.family))@account.accountable = account_params[:accountable_type].constantize.newIn the Current docs they show how you can make this even cleaner by setting the default on the model using
Currentinstead of having to merge it in with params.@@ -19,3 +19,3 @@def create@account = Account.new(account_params.merge(family: current_family))@account = Account.new(account_params.merge(family: Current.family))@account.accountable = account_params[:accountable_type].constantize.newI was about to follow up with another PR that adds test for this controller and then uses the association fully...
I think that's the clearest option. I personally quite like the
default:option though.Great job on this, @dwightwatson!