Displaying 20 results from an estimated 100000 matches similar to: "ActiveRecord::RecordNotFound error"
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
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|
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
2009 Nov 01
5
Headache with sessions being shared.
I have a really horrendous problem with sessions.
before_filter :find_cart_from_session
private
def find_cart_from_session
if session[:cart] # if there''s is a cart in the session
begin
@cart = Cart.find(session[:cart]) # return existing or new cart
rescue ActiveRecord::RecordNotFound
@cart = Cart.create
@cart.save
session[:cart] = @cart.id
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
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
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 =>
2009 Mar 25
6
Hash with key and value from ActiveRecord?
Heya,
I think I have thinking barrier. I just want a simple hash out of an
ActiveRecord.
@attributes = Attribute.find_all_by_character_id(@character).hash {
|u| [u.name, u.value] }
and I would like to access it like
@attributes[:health]
but it doesn''t work. Anyone can help me out with that?
--
Posted via http://www.ruby-forum.com/.
2008 Nov 13
5
Touch an ActiveRecord - timestamps
When I update an ActiveRecord, i would like to "touch" one of the
related objects, that the updated record belongs_to, in order to update
the timestamps on the parent record, although i don''t want to change any
of the data in the parent. Whats the accepted way to do this?
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You
2007 Dec 07
7
activerecord 2.0.1 gem
I have tried to install activerecord 2.0.1 both through gem update and
by manually downloading it and doing gem install. They both fail with
MANUAL:
C:\DRC\ruby>gem install activerecord-2.0.1
ERROR: Error installing gem activerecord-2.0.1[.gem]: buffer error
REMOTE:
R:\workzone\dwell-aware\trunk>gem update --source
http://gems.rubyonrails.com
Updating installed gems...
Attempting remote
2007 Aug 23
6
Saving ActiveRecord in PostgreSQL without id
I have a small table that is used to temporarily queue requests, as such
it does not have an id field (or any other primary key), because it
doesn''t make sense to have one.
When I created an ActiveRecord class and tried to save it, I get:
ActiveRecord::StatementInvalid: PGError: ERROR: relation
"temp_requests_id_seq" does not exist
It keeps looking for the id to auto
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 =
2007 May 02
2
WHERE NOT syntax with ActiveRecord
I need to run a sql statement along the lines of SELECT * FROM items
WHERE NOT ... But I would like to run this in the ActiveRecord syntax. I
like using :conditions => [...] but obviously where it renders ''WHERE
NOT'' and not simply ''WHERE''. I''d rather not use find_by_sql if at all
possible for security reasons. Anyone know how to do this?
Thanks,
2007 Dec 14
17
Rails 2.0.1 RC2 - activerecord-oracle-adapter not found
Hi,
Does anyone know why gem can''t find activerecord-oracle-adapter?
C:\>rails --version
Rails 2.0.1
C:\>gem install activerecord-oracle-adapter
ERROR: While executing gem ... (Gem::GemNotFoundException)
Could not find activerecord-oracle-adapter (> 0) in any repository
It all started when I tried to run Mongrel on a Win32 box:
C:\web\FDS_Server>mongrel_rails start
2007 Mar 28
4
Disabling ActiveRecord "type" column subclassing
Hi! I have a legacy table that has a column named "type" and need to
remove this automatic subclassing by ActiveRecord. The api pages are
vague about this, and I tried
self.inheritance_column = "xtype"
which seemed to get me half-way. In the validate_on_create method, the
value of self.type was my model Class name.
How would you disable this feature?
--
Posted via
2007 May 15
4
Way to mark record as main?
I was curious if there was a built in feature in ActiveRecord or a
plugin, but I basically have a database for phone numbers. I want a user
to be able to make a phone number as main. There can only be one phone
number marked as main at all times. Is there something for this?
Thanks for your help.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
2009 Sep 01
13
Function Testing Reloading Fixtures before assertion
Hey Everyone,
I have a function test the is failing (despite the fact the function
actually works in the application). I was looking for some debug
advice on how to find my problem.
Here is the test:
def test_should_delete_word
assert_equal ''published'', words(:one).status
debugger
delete :destroy, :id => words(:one).to_param
assert_equal
2008 Sep 17
13
Capturing the sql from a statement without executing it?
Hi guys,
Is there an elegant way to capture the sql that would have been
executed by an ActiveRecord statement, without actually executing
it? :)
I''m imagining something like
sql = User.find(1).groups.to_sql
or perhaps
sql = ActiveRecord::Base.capture_sql { User.find(1).groups }
resulting in sql = ''SELECT * FROM groups INNER JOIN memberships....
WHERE users.id =
2007 Jan 20
1
Missing action error not being caught
I keep getting a blank page containing only the following:
"There was a controller specfic error processing your request."
Though I have the following in my application.rb
def rescue_action_in_public(exception)
case exception
when UnknownAction, ActiveRecord::RecordNotFound then
render :controller => "application", :action =>
2008 Jan 18
8
link_to problem
hi @ all
I create a new archiv.html.erb and a archiv method in the controller.
Now, I would like to link from index.html.erb to archiv.html.erb. I
tried to use <%= link_to ''archive'', archiv_xxx_path %> but it doesn''t
run.
It appears a error message "SyntaxError in xxx#index".
Does anyone know, how I can enhance this problem?
thanks a lot...
--
Posted