Formatting a pretty page for 'raise' errors

Hi,

I’m using the following code to handle an error

unless user_can_view_group
  raise "User does not have permission to view group'"
end

Which happily prevents users from viewing groups. But the error page
is rather ugly, and I’d like to pass the raise string to a view which
can give them a nicer looking error page. Is this possible?

Luke

On Jun 26, 2007, at 1:01 AM, luke wrote:

unless user_can_view_group
  raise "User does not have permission to view group'"
end

Which happily prevents users from viewing groups. But the error page
is rather ugly, and I’d like to pass the raise string to a view which
can give them a nicer looking error page. Is this possible?

Instead of raising an exception you can handle that with a regular view:

unless user_can_view_group
@msg = “User does not have permission to view group”
render :action => ‘generic_message’
end

– fxn

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs