patternrubyrailsMinor
Routes for reminders
Viewed 0 times
remindersroutesfor
Problem
I have a controller with just a few actions, not the whole 7 RESTful actions situation. Here's what I have so far for routing:
I think there certainly has to be a way to express this in a more DRY way, but but I'm not sure how that might go.
Snip::Application.routes.draw do
get "appointment_reminder_responses/confirmation_thanks", to: "appointment_reminder_responses#confirmation_thanks"
get "appointment_reminder_responses/declination_thanks", to: "appointment_reminder_responses#declination_thanks"
get "appointment_reminder_responses/:hash", to: "appointment_reminder_responses#create", as: :create_appointment_reminder_response
endI think there certainly has to be a way to express this in a more DRY way, but but I'm not sure how that might go.
Solution
Not a lot to review,
obviously the most repeated part of your code is
Furthermore you create a function that takes a string and modifies so that
obviously the most repeated part of your code is
appointment_reminder_responses, if you create a variable called root and then built your routes with concatenations like root + "/confirmation_thanks" then that would be a good start.Furthermore you create a function that takes a string and modifies so that
"xxx/zzzz/yyyy" becomes "xxx/zzz#yyyy" and use that function for the first 2 routes.Context
StackExchange Code Review Q#44902, answer score: 3
Revisions (0)
No revisions yet.