Displaying 20 results from an estimated 110 matches for "recordnotfound".
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
# passes
it "should not assign an...
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
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.
Finaly, this is where I have a problem, on the third line, I want to see
if the record was deleted. I though about using...
2005 Jun 30
2
Find by ID plus conditions -> ActiveRecord::RecordNotFound
...''17'',''36'',''39'',''54'') AND (private = 0 OR (private = 1 AND user_id = 1)) ORDER BY id
But when the conditions supplied reduce the actual number of notes
returned (e.g. the note with id 54 is excluded) then I get an
ActiveRecord::RecordNotFound, which is raised in active_record/base.rb
line 356:
if result.size == ids.size
return result
else
raise RecordNotFound, "Couldn''t find all #{name.pluralize} with IDs (#{ids_list})#{conditions}"
end
(I have active record version 1.10.1)
The ability to supply a :conditions...
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 exception is not raised ... did I miss something...
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 r...
2010 Aug 08
2
issue with rescue_action_in_public! and testing 404 responses
...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 example to fail since the exception
propagates out of the controller into the spec.
>From googling around I get that rails only handles the exceptions and does a
404 response when it''s run in production mode, and that you need to ca...
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_reque...
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|
for...
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 Trace
D:/Ruby/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:939:in
`find_from_ids''
D:/Ruby/Ins...
2006 Feb 16
3
rescue_action_in_public question
...''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
logger.error("404 displayed")
render(:file => "#{RAILS_ROOT}/public/404.html",
:status => "404 Not Found")
else
logger.error("500 displayed")
render(:file =>...
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[:...
2006 Mar 15
4
ActiveRecord::RecordNotFound in search results act_as Ferret
...d
I''ve done some updates and the index files seem to be being generated
ok.
If I go to mywebapp/ferret/find?search_terms=gamston where "gamston" is
the name of one of the branches I get
--- []
as the result.
If I go to mywebapp/ferret/find?search_terms=* I get
ActiveRecord::RecordNotFound in Ferret#find
Couldn''t find Branch with ID=5
There are no Branches with an ID of 5. Does anyone have any ideas whats
going on with my system. I tried my best to trouble shoot the issue but
to no avail.
Any help is appreciated.
Tom Styles
--
Posted via http://www.ruby-forum.com/.
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
2008 Mar 17
4
RSpec''ing model association callbacks
Hi all,
i''m learning rspec and i must admit i really love it.
But at the time i started learning it, i already
developed my models classes and their callbacks.
Now i''m trying to get a 100% coverage of my code but i
cannot reach it because i do not understand how to
spec my callbacks.
Look at this for example:
----------------- User Model
class User < ActiveRecord::Base
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 => 404
end
def show_error(exception)
render :text => exception.message;
end
and was quit...
2007 Oct 08
6
spec''in controllers request for nested routes
...def do_get
get :index, :game_id => @game
end
it "should be successful" do
do_get
response.should be_success
end
it "should render index template" do
do_get
response.should render_template(''index'')
end
end
1)
ActiveRecord::RecordNotFound in ''PlayersController handling GET
/saltmines/games/1/players should be successful''
Couldn''t find Game with ID=#<Spec::Mocks::Mock:0x2ffcde4>
/Volumes/EXTERNAL/web/omenking.ca/config/../app/controllers/players_controller.rb:5:in
`index''
/Volumes/EXTERNAL/we...
2006 Jun 02
7
Unit Tests crashing out for a table without an ID
...r 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 when I try to do any unit-testing of
my User model I get this:
ActiveRecord::RecordNotFound: Couldn''t find UserQuestionResponse without
an ID
.../gems/activerecord_1.14.2/lib/active_record/base.rb:932:in
''find_from_ids''
Any ideas what is going on and what I can do about it?
--
Posted via http://www.ruby-forum.com/.
2006 Mar 08
0
Unit tests dynamic finders
....yml:
first_answer:
id: 1
question_id: 1
question_test.rb:
class QuestionTest < Test::Unit::TestCase
fixtures :categories, :questions, :answers
def test_destroy
question = questions(:first)
id = question.id
question.destroy
assert_raise(ActiveRecord::RecordNotFound) {Question.find(1)}
assert_raise(ActiveRecord::RecordNotFound) {Answer.find(1)}
assert_raise(ActiveRecord::RecordNotFound)
{Answer.find_by_question_id(1)} <<TROUBLE, ACTUALLY SUCCEEDS
#assert_raise(ActiveRecord::RecordNotFound) {Answer.find(:all,
:conditions => &q...