similar to: handling ActiveRecord::RecordNotFound

Displaying 20 results from an estimated 1500 matches similar to: "handling ActiveRecord::RecordNotFound"

2009 Feb 10
2
rescue_from for NoMethodError
Hi everyone, I was just trying to catch some exceptions in my app, for "Record Not Found" I used this in my application.rb file rescue_from ActiveRecord::RecordNotFound, :with => :record_not_found rescue_from ActionController::NoMethodError, :with => :show_error private def record_not_found render :text => "404 Not Found", :status =>
2010 Aug 08
2
issue with rescue_action_in_public! and testing 404 responses
Hello, I''m new to rails and I''m trying to wrap my heads around how to spec controllers using RSpec (using rails 3rc1 and rspec 2.0.0.beta.19). The problem I''ve run into is when I want to test that my controllers respond with a 404 for unfound records. Whenever I run the spec, the ActiveRecord::RecordNotFound exception is not caught by rails, causing the spec
2007 Dec 22
8
Rails 2.0 rescue_from
I am trying to use the new Rails 2.0 macro : rescue_from class PostsController < ApplicationController rescue_from ActiveRecord::RecordNotFound, :with => :deny_access ... def show @post = Post.find_by_id(params[:id]) raise ActiveRecord::RecordNotFound if @post.nil? #illegal access ..... end def deny_access respond_to do |format| format.html end end but the
2005 Aug 21
2
ActiveRecord::RecordNotFound
Is there a specific reason why AR doesn''t raise a RecordNotFound exception in any exception other than "find(id)"? It would seem to be more consistent with the unified find if all types of find would raise a RecordNotFound exception. jim jim-rhf1kIDhBaeB8E1WFlbJj6xOck334EZe@public.gmane.org
2007 May 08
2
ActiveRecord::RecordNotFound error
I was having problems with ActiveRecord::RecordNotFound in my code, so did a search on the forum here, and I got an application error. search string: ActiveRecord::RecordNotFound I am just reporting this so somebody could fix the problem? Andrew -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are
2005 Jun 30
2
Find by ID plus conditions -> ActiveRecord::RecordNotFound
Hi I''m trying to understand the AR find facilities, described here: http://api.rubyonrails.com/classes/ActiveRecord/Base.html#M000650 I have a list of ids that I want to retrieve, but have a condition that should restrict the list returned: return self.find( noteids, :conditions => [ "(private = 0 OR (private = 1 AND user_id = ?))", userid] ) According to the
2008 Nov 17
2
Can't seem to test http error codes
in application.rb rescue_from ActiveRecord::RecordNotFound { |e| http_status_code (:missing, e) } def http_status_code(status, exception) @exception = exception respond_to do |format| format.html { render :template => "shared/status_# {status.to_s}", :status => status } format.any { head status } end end in a controller project =
2006 Jul 03
2
Agile Web Dev on Rails - ActiveRecord::RecordNotFound Prob
Hi there I''ve also made a start on the Agile Web Dev using Rails book! I''ve been hit with a problem when hitting the ''Add to Cart'' button - I get the following error message: ActiveRecord::RecordNotFound in StoreController#add_to_cart Couldn''t find Product without an ID RAILS_ROOT: ./script/../config/.. Application Trace | Framework Trace | Full
2006 Mar 15
4
ActiveRecord::RecordNotFound in search results act_as Ferret
Hello, I''ve installed the Ferret gem and also got the act_as_ferret code from the wiki. I''ve set up my model "Branch" to act as ferret using the code below. acts_as_ferret :options => {:fields => [''name'', ''body_text'', ''address'']} I''ve also set up a ferret_controller with the code below def find
2007 Oct 29
1
(PR#10379) Re: x11(....) kills R without DISPLAY
Hin-Tak Leung wrote: > Peter Dalgaard wrote: > <snipped> >> You need x11() with a valid display to trigger the bug: >> >> [pd at titmouse2 BUILD]$ ssh -Y 192.168.1.10 >> pd at 192.168.1.10's password: >> Last login: Sat Oct 27 02:40:16 2007 from 192.168.1.11 >> [pd at janus ~]$ echo $DISPLAY >> localhost:10.0 >> [pd at janus ~]$
2006 Jan 09
1
Problem with RecordNotFound without numeric id
Hi all, I have a problem handling errors for RecordNotFound (Page 86 of Agile Book), I want to redirect bad items id to "list" with a flash "Invalid Item", but this works only with numeric id, if I use some like "wibble" the result is an empty list of items. This is in my item_controller: def show @item = Item.find(params[:id]) rescue redirect_to :action
2009 Feb 06
6
RecordNotFound bubbling thru to cucumber
Hello, I have a controller action that raises a RecordNotFound exception if you''re not allowed to see something. In my global application controller (application.rb), I catch these and render the 404 template. But when I run cucumber (using webrat), it''s getting the full stacktrace (the step blows up). Any ideas why? I have consider_all_requests_local turned off in my test.rb.
2006 Feb 15
0
Multiple Conditions and ActiveRecord::RecordNotFound
Hey all, It seems that if I do a Foo.find(:first, :conditions => ["identifier = ?", content_identifier]) and no records are returned then I get the exception thrown. When I add a second condition Foo.find(:first, :conditions => ["identifier = ? AND bar = ?", content_identifier, "1"]) Even though again no records are returned, the exception isn''t
2009 Nov 10
1
ActiveRecord::RecordNotFound in LookController
I am finding this error.pls help me
2009 Dec 25
18
rescue_from ActionController::RoutingError II
OK ... so I''m not supposed to use it but ... Why doesn''t rescue_from ActionController::RoutingError work witht he code from http://www.rubyplus.org/episodes/20-Extended-RESTful-Authentication-Rails-2-App.html class ApplicationController < ActionController::Base helper :all # include all helpers, all the time # See ActionController::RequestForgeryProtection for details
2012 Aug 28
4
ArgumentError in HomeController#index
Hey guys, I''m new to ruby/rails and trying to sort something... I just created an app with composer, http://railsapps.github.com/rails-composer/ I used the command: rails new myapp -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb I set up the rails server, and tried to load the app on localhost:3000 However, I end up with: ArgumentError in HomeController#index
2010 Mar 28
3
ActionController::UnknownHttpMethod: ***, accepted HTTP methods are get, head, put, post, delete, and options
I''m occasionally getting exception notices with this error message: ActionController::UnknownHttpMethod: ***, accepted HTTP methods are get, head, put, post, delete, and options Anyone ever seen this or know what could be causing it? Thanks, Jeff -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this
2011 Jun 05
1
Cancan redirect back at AccessDenied
Hello I have a rails 3 app and I am trying to implement the redirect back action at access denied for cancan. If I try this in my application_controller: rescue_from CanCan::AccessDenied do |exception| redirect_to :back end It gives the following error: No HTTP_REFERER was set in the request to this action, so redirect_to :back could not be called successfully. If this is a test, make sure
2008 Apr 30
7
rescue_from issue with AWS - uninitialized constant
The new rescue_from in edge rails seems to conflict with ActionWebService, which I need for various other purposes. When I define, for example (with AWS gem installed): <b>rescue_from ActionController::RoutingError, :with => :page_not_found</b> I get the exception: <b>uninitialized constant ActionWebService::Dispatcher::ActionController::Base</b> OK, so AWS
2013 Nov 12
7
Hook into Exception Chain
Hi there, I''m using Log4r in my rails projects. On log.error an email is sent using the EmailOutputter. I know changed the EmailOutputter to include a global var in the subject (MDC) since the subject is normally static. I want to set this var to the exception message, so it is sent as the subject. Can anyone tell me how to do this in rails? Basically: raise e or some other cause