ruby on rails - How to set the HTTP status code on a filter? -


how can set http status code when controller filter condition not met?

for example, in following controller

class foocontroller < applicationcontroller   before_filter :foo_filter    def action      respond_to :html   end    private    def foo_filter     return false unless some_conditions   end end 

i set http status code 410 when calling action some_conditions being false. how can that?

i have 2 applications running, 1 in rails 3 , in rails 2, i'm interested in answer each rails version, if different.

class foocontroller < applicationcontroller   before_filter :foo_filter    def action     respond_to :html   end    private    def foo_filter     head :gone unless some_conditions   end end 

Comments