Hello,
I did not check if it was still there in Rails 3, but in rails 2,
ActionController::Base#render accepts a :nothing options used to render
empty text :
usage :
render :nothing => true, :status => whatever
And you have a short cut method for "only headers"
response ActionController::Base#head
usage :
format.xml { head :forbidden }
Mickael
On 12 June 2010 00:59, Satsou Sa <[email protected]> wrote:
> Hello all,
>
> I am working on Rails 3, and I would like to return a forbidden error
> message from a controller.
>
> I had trying something like that:
>
> def my_action
> respond_to do |format|
> format.html { redirect_to(login_path, :warning =>
> I18n.t('.forbidden'), :status => :forbidden) }
> format.xml { render :xml => I18n.t('.forbidden'), :status =>
> :forbidden }
> end
> end
>
> But it is not want I need, because I don't want to redirect to a
> particular page, such as login. I just want to return a standard 403
> error (with raise maybe). Is that possible?
>
> Thank you for your help.
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<rubyonrails-talk%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.