I am trying to create an simple link hider to hide external links.
I was thinking about creating a controller named Links:
class links < ApplicationController
def index
redirect_to :(My link column)
end
end
And my database should be something like this:
ID link
1 http://stackoverflow.com
2 http://google.com
Example if I visit links/index/1 i would be redirected to http://stackoverflow.com
How do I redirect to the link that in the link column?
Assuming your Link model doesn’t do anything out of the ordinary, you can do something like this…
controller.rb