similar to: Find by ID plus conditions -> ActiveRecord::RecordNotFound

Displaying 20 results from an estimated 1000 matches similar to: "Find by ID plus conditions -> ActiveRecord::RecordNotFound"

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
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 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
2009 Apr 12
1
handling ActiveRecord::RecordNotFound
How should we handle requests for invalid objects which do not exist in database, ActiveRecord::RecordNotFound error ? I am writing begin-rescue as follows: def show begin @phone = Phone.find(params[:id]) rescue ActiveRecord::RecordNotFound flash[:notice] = NONEXIST_OBJECT redirect_to :controller => :phone, :action => :index else respond_to do |format|
2006 Apr 01
12
Repost: Why is rails generating bad SQL?
It looks like I am missing something obvious. ActiveRecord is generating _really_ bad SQL for this configuration, and I can''t quite figure it out. I''ve instrumented ActiveRecord enough to localize the problem somewhat, and generally by this time I would have a good idea of what I was missing because it''s all in the source. It appears that something in
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
2008 Feb 13
5
Example controller spec no worky?
I''m trying to spec a dead simple "show non-existent record should render 404" case, but it seems the RecordNotFound exception is making it impossible for some reason. #controller def show @event = Event.find(params[:id]) end #spec - pretty much straight from the rspec site before do Event.stub!(:find) get :show, :id => ''broken'' end #
2006 May 06
6
assert_raises --> how does it work?
Hi, I have this code fragment: def test_delete_concept assert_not_nil Concept.find(concepts(:entreprise).id) get :delete_concept, {:concept_id => concepts(:entreprise).id} assert_raises :RecordNotFound, Concept.find(concepts(:entreprise).id) end basicaly, on the first line, I make sure that the concept exist in the DB. On the second line I delete the concept fron the DB.
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
2006 Feb 16
3
rescue_action_in_public question
I''m using the rescue_action_in_public example from the Agile book to handle errors and email serious ones to me. In my application.rb controller: def rescue_action_in_public(exception) logger.error("rescue_action_in_public executed") case exception when ActiveRecord::RecordNotFound, ActionController::RoutingError, ActionController::UnknownAction
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 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
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 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 =>
2006 Jun 02
7
Unit Tests crashing out for a table without an ID
I''m having problems unit testing my model- I have a kind of quiz functionality user table and a question table and a user_question_response table that contains the id for the user, the id for the question and the user''s response. The user_question_response has it''s own model belongs_to/has_many with users and questions and it works fine in the actual application but
2006 Feb 08
1
functional test problem
I am trying to write a test for my delete method. I find a User in the db by its id, do the delete action, then I want to see if it is still in the db. How do I check that the User IS Deleted without causing errors? ** My Test ******************************** def test_delete_user login user = User.find(2) post :delete_user, {:id => user.id} assert_equal "User
2005 Dec 16
1
Exception Locations?
I am trying to locate the following in the current 1.0 source tree: ActiveRecord::RecordNotFound ActionController::UnknownAction Looking at the API docs, I''ve been unable to track these down. Can someone help?
2007 Oct 08
6
spec''in controllers request for nested routes
describe PlayersController, "handling GET /saltmines/games/1/players" do before do @game = mock_model(Game, :to_param => "1") @game.stub_association!(:players, :find => mock_model(Player)) end def do_get get :index, :game_id => @game end it "should be successful" do do_get response.should be_success end it "should
2009 Oct 28
2
mislav-will_paginate(will_paginate)
mislav-will_paginate(will_paginate) doesn''t work after search. servers_controller.rb def index @servers = Server.paginate(:page => params[:page], :per_page => 20, :order => ''device_id ASC'') respond_to do |format| format.html # index.html.erb format.xml { render :xml => @servers } end end def search @servers =