Suppose I use a custom :format
to implement a gadget-oriented version of my site. The general idea is that I can reuse controllers with custom, gadget-oriented views.
Is there any way to make all URL helpers called from that particular format keep the same format, without hardcoding it into all helpers?
I'd like to keep controllers untouched, and redirect_to
calls from the controllers ignore the current format.
nevermind, found an elegant solution:
def default_url_options(options = nil) options ||= {} options[:format] = :gadget if request.format == :gadget options end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.