1

I have a rails app but I need to route old routes from a php app to my new rails routes (because of old google ads tied to them). I have looked far and wide and I can't figure out how to solve my problem.

I have a videos controller where my new videos use "friendly id". Now, I have old routes, where they use both slugs and ids. I need to redirect these old routes to my new routes. I know that I need to check is the video is nil, but I'm trying to figure out how to define what slug goes where.

My issue: I am trying to do the simple reroute thing, but my controller is trying to located the id and is unable to find them (since the slugs are no longer valid) and it throws an error. I have a list of 6 videos that I need to reroute to my new routes.

Any suggestions on what I'm missing?

Routes

get '/videos/toys' => redirect('/videos')
get '/videos/88' => redirect('/videos/cool-video')
get '/videos/1388' => redirect('/videos/better-video')
get '/videos/tech-video' => redirect('/videos/technologies-video')

For example, I have a tech-video, old slug, that needs to go to the new "technologies video" or I have an id of '88' that needs to go to "cool-video"

Controller

(bottom of controller)
private

def set_video
  @video = Video.friendly.find(params[:id])
  if @video.nil?
    **method goes here**

  end
end
4

1 に答える 1

0

チャットでわかったように、ルートがないことを確認してください'videos'

(含むresources :videos)

リダイレクトが開始される前にルートを含むルート/videos/:idが一致するため、リダイレクトの上のルート ファイルで発生します。

幸運を!!

于 2015-12-10T05:44:07.793 に答える