Hi
I have controller edit action like
def edit
begin
@user = User.find(params[:id])
rescue ActiveRecord::RecordNotFound
logger.warn "User with id #{current_user.id} tried to edit user with
id #{params[:id]}"
render :file => "#{RAILS_ROOT}/public/404.html"
else
-------
end
end
And suppose if current_user has noa ccess to user with id = 10.Then
when try
http://localhost:3000/edit/10
This will render the 404.html
Now my problem is suppose if the user try something like
http://localhost:3000/edi123t/10
Then what I get is a routing error. I dont know how to handle this.
Please help.
Thanks
Tom
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Well you can specify a default page / controller action to perform for unmatched routes as well...so if the route doesn''t exist it shows a much user friendly page instead of the rails error message Thanks & Regards, Dhruva Sagar. On Mon, Apr 26, 2010 at 13:52, Tom Mac <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi > I have controller edit action like > > def edit > begin > @user = User.find(params[:id]) > rescue ActiveRecord::RecordNotFound > logger.warn "User with id #{current_user.id} tried to edit user with > id #{params[:id]}" > render :file => "#{RAILS_ROOT}/public/404.html" > else > ------- > end > end > > And suppose if current_user has noa ccess to user with id = 10.Then > when try > http://localhost:3000/edit/10 > This will render the 404.html > > Now my problem is suppose if the user try something like > http://localhost:3000/edi123t/10 > Then what I get is a routing error. I dont know how to handle this. > Please help. > > Thanks > Tom > -- > 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.
Hi Thanks. But how can I handle in code? Tom -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi,
In application controller
rescue_from
ActiveRecord::RecordNotFound,ActionController::RoutingError,
ActionController::UnknownController,
ActionController::UnknownAction, ::NoMethodError,
:with => :handle_exception
# To handle Exceptions
def handle_exception
redirect_to no_access_url # redirect to a page with u need show
end
--
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.