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
<lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> 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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To unsubscribe from this group, send email to
>
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
> .
> 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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.