Skip to content

Commit

Permalink
Use the new params.expect
Browse files Browse the repository at this point in the history
  • Loading branch information
miharekar committed Jan 18, 2025
1 parent ea076e0 commit 9417cfc
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ AllCops:
- db/schema.rb
- db/migrate/*
- bin/*
- lib/misc/snippets.rb

Bundler/OrderedGems:
Enabled: true
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/coffee_bags_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def load_roasters
end

def coffee_bag_params
cb_params = params.require(:coffee_bag).permit(:name, :url, :roaster_id, :roast_date, :roast_level, :country, :region, :farm, :farmer, :variety, :elevation, :processing, :harvest_time, :quality_score, :tasting_notes, :image)
cb_params = params.expect(coffee_bag: %i[name url roaster_id roast_date roast_level country region farm farmer variety elevation processing harvest_time quality_score tasting_notes image])
roaster = Current.user.roasters.find_by(id: cb_params[:roaster_id])
cb_params[:roaster_id] = @roaster.id if roaster.blank?
cb_params
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/profiles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def profile_params
allowed_params << %i[coffee_management_enabled] if Current.user.premium?
notification_settings = {unsubscribed_from: (User::EMAIL_NOTIFICATIONS - params[:user][:email_notifications]) || []}

params.require(:user).permit(allowed_params).merge(chart_settings).merge(notification_settings)
params.expect(user: [allowed_params]).merge(chart_settings).merge(notification_settings)
end

def chart_settings
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/push_subscriptions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ def create
private

def push_subscription_params
params.require(:push_subscription).permit(:endpoint, :p256dh_key, :auth_key)
params.expect(push_subscription: %i[endpoint p256dh_key auth_key])
end
end
2 changes: 1 addition & 1 deletion app/controllers/roasters_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ def load_roasters
end

def roaster_params
params.require(:roaster).permit(:name, :website, :image)
params.expect(roaster: %i[name website image])
end
end
2 changes: 1 addition & 1 deletion app/controllers/shots_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,6 @@ def update_shot_params
allowed = [:image, :profile_title, :barista, :bean_weight, :private_notes, *Parsers::Base::EXTRA_DATA_METHODS]
allowed << [:tag_list, {metadata: Current.user.metadata_fields}] if Current.user.premium?
allowed << :coffee_bag_id if Current.user.coffee_management_enabled?
params.require(:shot).permit(allowed)
params.expect(shot: [allowed])
end
end
2 changes: 1 addition & 1 deletion app/controllers/updates_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ def set_update
end

def update_params
params.require(:update).permit(:title, :body, :published_at, :image, :excerpt)
params.expect(update: %i[title body published_at image excerpt])
end
end

0 comments on commit 9417cfc

Please sign in to comment.