lundi 15 juin 2015

How to redirect to current path without format (.json, .xml -> .html)

If I have an unpermitted user trying to request a JSON or CSV file how can I redirect them to the same path but without the format.

  def some_before_filter
    if !current_admin_user.can_download_resources? and request.format != "text/html"
      request.format = "text/html"
    end
  end

This directs to the root_path, not the current request without format.

RoR 3.2

Aucun commentaire:

Enregistrer un commentaire