views:

142

answers:

1

I'm trying to call a custom instance of a 403 HTTP error in Rails but I can't seem to figure out how to do this...

I have several user authentication roles and basically if a role tries to browse to an area that it is not authorised to visit I want to display a 403 instead of just redirecting the user.

How do I do this?

+3  A: 

In your controller code add the following line:

render :status => :forbidden, :text => "Forbidden fruit"

Refer to this page for http code to symbol mapping.

KandadaBoggu
Fantastic! Thanks heaps... FYI you're missing a comma after :forbidden
Ganesh Shankar
Thanks I have updated the answer and added a reference to http code to ruby symbol list.
KandadaBoggu