Displaying 20 results from an estimated 10000 matches similar to: "How to placing common exceptions for all models in single method?"
2007 Oct 21
7
exact exceptions in rescue_from
rescue_from stores exception class names in a hash table, and
associates them with handlers.
When an exception is raised there''s a name lookup, and if an entry is
found its handler is invoked. In particular rescue_from does not
emulate Ruby''s rescue semantics with regard to inheritance.
Which is the rationale? Don''t you think taking is_a? and declaration
order
2008 Feb 07
2
Catching non-Merb::ControllerExceptions Exceptions
Is there an agreed upon method for handling exceptions thrown by
something outside of Merb? For example, DataMapper now throws a
DataMapper::ObjectNotFoundError when a record isn''t found in the db.
I''d like to catch these exceptions and raise a C:E:NotFound exception
instead, but without having to wrap a lot of code in begin/rescue/end
blocks.
Thanks,
Mike Irwin
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
2011 Mar 02
1
Designing Relation Ship Between Different Models
Hi
I have One Problem
For Example if You Take
Category has_many :products
Here For Category i have soap as example
for products i am taking Santoor , Lux and Rin soaps as products.
Here Again
Both Lux and santoor comes under Bathing soaps.
Rin Soaps Comes under Washing Soaps
So these are sub categories...
Tom-arrow some new sub category may come like baby soaps..
I am confusing How many
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 =>
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
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
2008 Sep 02
4
Rescue rails errors
Hi all,
Sometime, I get the following error in my application:
ActionController::InvalidAuthenticityToken in
ManageController#site_servers
ActionController::InvalidAuthenticityToken
I tried to put the code in manage controller between begin ... rescue
... end but it didn''t catch the error.
So I tried in the application.rb controller, I put the forgery code
between begin ... rescue ...
2008 Oct 24
1
rescue_from and assert_raise
Since commit 5e3517ea7b9fbd460f772bffc9212d882011f2bc, rescue_from is
now being handled in tests. I''ve been using rescue_from to handle
custom exceptions and testing that those exceptions are raised in
functional tests with assert_raise. This no longer works now. What''s
the proper way to test this now?
--~--~---------~--~----~------------~-------~--~----~
You received this
2010 Jul 26
2
Exception Pages when behind a proxy
I am not sure if this desired feature or not but when we are behind a
local proxy ie. Nginx/Varnish then the new ShowException middleware
doesn''t seem to properly detect the remote IP address and it appears
as if every browser gets a local error page with a stack trace, etc.
I''ve opened up a ticket on the rails bug tracker but I also would like
to verify that this is in fact a
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
2009 Mar 20
1
bypass_rescue and its inverse
Hey,
I''ve just started using rspec-rails 1.2 and the bypass rescue
declaration is wonderful - by default I tend to write controller which
raise exceptions (in exceptional circumstances), along with before-
filters as guard clauses, so being able to switch off rescue from
(which I properly spec separately) is a real boon.
Such a boon, in fact, that I immediately shoved it into a
2009 Jun 01
2
Placing multiple sound clips in a single file
Hello,
I strongly recall mention of people storing multiple small sound clips in
a single ogg vorbis file and then referencing them within the file, rather
than having multiple small files. However, Google has failed to turn up
anything posted about this.
My friend is thinking of using this technique to cut down on the space the
sounds take up in his games client. He is interested in
2011 May 09
1
Gluster text file configuration information?
Where can I find documentation about manual configuration of Gluster
peers/volumes? All documentation seems to be about the gluster CLI. I
would prefer manual configuration to facilitate automation via scripts
(e.g. Puppet/Chef).
I also read in this list that it is possible to configure Raid10 via
text files... I would also like to experiment with this setup. Any
related documents on how to do
2008 Aug 21
1
rescue_from failing to rescue [from]
Having some weird failures of rescue_from in all my specs. They still
rescue in actual usage, just not in my specs. Made a pastie of the code:
http://pastie.org/257399 This is with latest [as of 1:00 PM Eastern time
zone] rspec/rspec-rails/edge. Thanks in advance for any replies on this.
RSL
--
Posted via http://www.ruby-forum.com/.
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 =
2011 Jul 04
1
placing multiple rows in a single row
Dear people from the R help list,
I have a question that I can't get my head around to start answering,
that is why I am writing to the list.
I have data in a format like this (tabs might look weird):
John A1 1 0 1
John A2 1 1 1
John A3 1 0 0
Mary A1 1 0 1
Mary A2 0 0 1
Mary A3 1 1 0
Peter A1 1
2008 Mar 19
2
rescue
Hi, whats the correct way to spec a rescue? This will raise it but
doesnt test my code''s response
# controller
def edit
@foo = Foo.find(params[:id])
rescue
flash[:notice] = "Unknown foo #{params[:id]}"
redirect_to foos_path
end
# spec
it "should flash error if not found" do
Foo.should_receive(:find).and_raise
get :edit, :id
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 Jun 09
4
Measuring migration downtime
Hi,
I need to get the exact downtime for doing a live migration with ms
precision.
(I am not bothered about whole migration time which is close to 1 minute..
I need to measure
the live migration downtime during which the DomU is out of service.. the
figure quoted in the xen
documentation says it as ~60 ms.. )
I hope someone must have tried to measure this before.
Can you suggest me ideas