Hello all,
I have been updating the DatabaseForm extension with some extra functionality that a client of mine needed and I ran into a snag in page.process. I have since fixed it, but I wanted to see if anyone else has had this problem and see if there are any best practices. The line in question is
database_form_page.rb, line 23:
response.redirect(redirect_to)
I was getting a argument number error, so I had to dig through the docs for ActionController::CgiResponse, which informed me I had to give a status code. I tried 307 (temporary redirect), but that didn't have the browser behavior I wanted. So I came up with this solution:
#Trim the leading / off the slug
redirect_to = redirect_to.gsub(/^\//, '')
@response.body = redirect_to
@response.body = Page.find(:first, :conditions => ["slug = ?", redirect_to]).render
the problem with this solution thus far is that it won't find a fully qualified slug path, but I'm not sure what the best way to go about this is. Help is always appreciated.
Charlie
p.s. I will be posting this all on github once I feel that it's good enough :)