-
Notifications
You must be signed in to change notification settings - Fork 844
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
refactors suggestion controller out of story controller #1414
refactors suggestion controller out of story controller #1414
Conversation
@pushcx This is ready for review. For some reason, I can't request for review, as the button is disabled for me. |
config/routes.rb
Outdated
|
||
# Mapping old routes to new routes. can be safely removed after the next deployment | ||
get "suggest", to: "suggestions#new" | ||
post "suggest", to: "suggestions#create" |
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.
Let’s use Rails’ resource routes for the new controllers, and be careful to route old URLs to the new actions so that people who have loaded old pages before the deploy don’t get errors as they submit/vote/hide/save/etc. (Note them with dated comments, we can delete them after a month or so.)
add an explicit note: I don't want to maintain the old URL routes, I want use the Rails routes conventions for these.
I am little confused here. Should I remove these two line ?
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.
Sorry I didn't explain that well, I was also misunderstanding what I was looking at.
The resources
line is perfect, I want us to use Rails conventions for these routes.
The old routes (your get
and post
here) should use redirect
, so:
get "suggest", to:redirect("/stories/suggestions/new", status: 302)
post "suggest", to:redirect("/stories/suggestions", status: 307)
(The post
uses HTTP 307 so that the browser will POST to the new URL instead of switching to GET, it's an old gotcha.)
And then please new route test in spec/routing/stories_spec.rb
:
# 2025-01: Redirects for PR #1414 which moved these routes
it "is temporary" do
expect(get("/stories/suggest")).to eq(302)
expect(Time.zone.today).to be_before(Date.new(2025, 3, 1))
end
This "time bomb test" will forcibly remind me to delete the redirects after giving people a few weeks to use any tabs they have open. (See 4fd296e for an example of where I did this before. These URLs are unpopular enough that I don't think we need to do the added, slow steps of replacing a 302 redirect with a 301 redirect.)
Weird error. Does anyone know what's happening ? This branch is passing tests locally
|
Sorry, that bug is my fault, from 259b911. I'll have a fix in a minute but I have to wait for Ruby 3.4.1 to install... |
Great! Thanks for refactoring this code, I'm really happy that you've started the process of cleaning up one of the most complicated and error-prone parts of our codebase. |
Overview
The goal is to make story controller light. This tackles part 1.
Testing
lobsters_suggestions-2025-01-04_16.20.01.mp4