Вот так сделал def index if params[:key].present? && (short_url = ShortUrl.get(params[:key])) path = build_path(short_url) short_url.view! redirect_to path.to_s else redirect_to root_url end end private def build_path(short_url) path = URI.parse(short_url.value) path.query = [path.query, URI.encode_www_form(redirect_params)].compact.join("&") path.to_s end def redirect_params params.permit!.except("language", "special", "controller", "action", "key").to_h end
Обсуждают сегодня