routing - Rails dynamic redirection -


i need create dynamic redirection model rails app. sort of similar wordpress redirection plugin, if have used anytime. http://wordpress.org/plugins/redirection/

what model store redirect_this_path string, , final_path should redirected to. if user comes app requesting redirect_this_path, redirected final_path.

if however, there no matching entry found in database, request should forwarded other routes defined in routes.rb file. so, redirection model filter requests , redirect requests has data , relay other requests routes defined in routes.rb file.

is there way can achieved, suggestions?

you should this: (for example in application controller)

def path_check   if request.path == path_that_needs_redirecting     redirect_to final_path   end end 

then use: (in application or every controller need in)

before_filter :path_check 

hope helps

edit

if have many paths need redirecting do

if paths_that_need_redirecting.include? request.path 

Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -