Forum: Ruby on Rails protect to_xml and/or disabled other format

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ffbe650dbc3cc97f561569ae0aa2994f?d=identicon&s=25 fmh (Guest)
on 2009-02-03 10:51
(Received via mailing list)
hello,
how protect to_xml and disabled other format or accpet only html
format

example : if user type in url www.mysite/controller.xml , i want to
redirect to another controller.

it's possible to use a routes to do that ?
D69d23d8e811e8ab2a8593380d6ede63?d=identicon&s=25 Jeff Emminger (jemminger)
on 2009-02-03 21:39
(Received via mailing list)
one way would be a before_filter, e.g.


class ApplicationController < ActionController::Base

  before_filter :trap_xml

  def trap_xml
    if params[:format] == 'xml' && params[:action] != 'my_xml_action'
      redirect_to :controller => 'my_xml_controller', :action =>
'my_xml_action'
    end
  end

end
Ffbe650dbc3cc97f561569ae0aa2994f?d=identicon&s=25 fmh (Guest)
on 2009-02-04 18:38
(Received via mailing list)
yes it's this.
thanks
This topic is locked and can not be replied to.