ruby - Override redirect_to in rails -
i utilize engine in rails app logins user , redirects service param (it's cas engine). however, host app want redirect user (after he/she has logged in) in different location depending on params. @ moment can't work because rails permits 1 phone call of redirect_to/render. engine inherits rails app applicationcontroller.
how can override/redefine redirect_to phone call multiple times?
the problem might solved in other ways don't want them. have tried of them none can compete simplicity of letting lastly defined redirect_to take action.
i'm only interested in solutions involve redefining redirect_to can invoke multiple times.
of course of study can "override" it. can redefine method in object @ point in ruby. however, terrible idea. should prepare problem, you're calling redirect_to twice, instead of hacking apart rails in order allow problem continue.
if you're still set on "fixing" wrong way, find source code (this trivially easy do), re-create initializer/library file of own, , create modifications.
module actioncontroller::redirecting def redirect_to(options = {}, response_status = {}) raise actioncontrollererror.new("cannot redirect nil!") unless options raise abstractcontroller::doublerendererror if response_body self.status = _extract_redirect_to_status(options, response_status) self.location = _compute_redirect_to_location(options) self.response_body = "<html><body>you beingness <a href=\"#{erb::util.h(location)}\">redirected</a>.</body></html>" end end if want this, despite beingness forewarned wrong solution problem , you're fundamentally altering behavior of rails other things may depend on, comment out line raises doublerendererror.
ruby-on-rails ruby redirect override
No comments:
Post a Comment