Displaying 20 results from an estimated 8000 matches similar to: "validations and directing errors"
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 Jun 20
2
Validation error_messages_for problem
I am having trouble getting error_messages_for to work.
My controller(relevant parts) looks like
def configure
@account = session[:account]
@user = User.new
end
def add_new_user_to_account
@user = User.new(params[:user])
if @user.valid?
session[:account].users << @user
end
redirect_to :action=> ''configure''
end
end
and my
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 05
5
Active Record, Migration, and Translation
Hi,
I think the columns and table in migration should be able to have an
optional "display_name" set manually. Something like:
create_table :people, {display_name => "Personne"} do |t|
t.column :first_name :string, :display_name => "Prénom".
end
Let me explain my point of view:
Rails is a framework made to write programs in English. You see it when
you
2006 Feb 07
1
AWDWR: NameError (uninitialized constant UnknownAction) in rescue_action_in_public
I copied (and modified) this code from AWDWR:
def rescue_action_in_public(exception)
case exception
when ActiveRecord::RecordNotFound,
ActionController::UnknownAction
render :template=>''/error'', :layout=>''application'',
:status=>''404 Not Found''
else
render :template=>''/error'',
2006 Feb 08
2
NameError (uninitialized constant UnknownAction)
Hi, I''m having a strange problem that only seems to be happening on our
production server. I never get this error locally but get it quite
often on the server. The other odd thing is it doesn''t seem to be
resulting in any error pages on the site. Everything looks fine...
I wanted to add a rescue_action_in_public to email me when there are
errors. So I followed the
2007 Sep 08
1
Unknown Action doesn't raise exception ?
As I am in development environment, I wrote in my config/environment.rb
ActionController::Base.consider_all_requests_local = false
in my application.rb, I wrote
def rescue_action_in_public(exception)
case exception
when RoutingError, UnknownAction
render :file => "#{RAILS_ROOT}/public/404.html", :status =>
404
else
logger.error
2006 Feb 03
2
testing to see if emails are sent out on exceptions
Hi,
I''m using ActionController::rescue_action_in_public() to send emails
when uncaught exceptions happen.
Is it possible to write tests for that?
Joe
2006 Jun 28
3
couple newbie questions
Hello Folks,
I am starting out with RoR and just browsed through Dave''s book ? couldn''t
stop reading. I started building a prototype to get better hands on
experience and I have run into two simple issues that I am hoping will be a
quick answer for some of you experts out there.
*Issue 1:*
>From within a "companies" controller and list_companies.rhtml view
2009 Feb 04
2
rendering error page for "Unauthorized" from before_filter
Hey all,
I am writing a plugin in which I want to stop the rendering of an
action with an unauthorized response if the user is not authorized to
view the resource. I am using a before filter to achieve this and
inside that before filter I do it like so:
render :text => "Unauthorized!", :status => :unauthorized, :layout
=> false
The status is properly set since I see the
2006 Sep 07
6
form_for - Child object - how to set parent id
Hi All,
I am just trying to learn ruby/rails so please don''t flame me if this is
a stupid question.
As a learning project I decided to create my own blog using ROR. I have
created a controller that shows paged blog entries, and below each blog
is a list of comments along with a form alowing the user to add a new
comment.
To create the form for the comment entry I used form_for
2009 Aug 14
9
Rescuing from REXML::ParseException
Hello,
When I call an action with some invalid XML or JSON data a parse
exception gets raised from within Rails/Ruby (REXML or
ActiveSupport::JSON). The problem that I''ve got is how to handle these
exceptions. In my application_controller.rb I have the following for
debugging purposes:
def rescue_action_in_public(exception)
respond_to do |request|
request.all { render :text =>
2006 Jan 27
17
Multiple Model Validation
Hey All !
I have a form which contains two models. I would like both models to be
validated, but have their validations aggregated on the page.
If I do:
<%= error_messages_for(:model1) %>
<%= error_messages_for(:model2) %>
It puts two big validation blocks on the page. I would like all the errors
from both models, but only in one validation box.
Is this possible ? All my attempts
2006 Jan 19
1
Model Validation & Floating Attributes
Hello all !
I have a model being validated that spits it''s error messages on the
resulting page using:
error_messages_for(:mymodel) .... Basic stuff. It''s working perfectly.
Now, I have something else I want to check on the same page (that isn''t an
attribute to the Model)... and am trying to add it using:
@mymodel.errors.add_to_base("another error here")
2006 Mar 22
1
undefined method `respond_to'' when using Exception Notifier Plugin
I''m trying to use the exception notifier plugin and I''m getting this error
message:
NoMethodError (undefined method `respond_to'' for
#<Adm::PeriodController:0xb74c9804>):
/vendor/plugins/exception_notification/lib/exception_notifiable.rb:64:in
`render_500''
/vendor/plugins/exception_notification/lib/exception_notifiable.rb:76:in
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 =>
2006 Apr 05
2
How to add add child items to parent via parent show view?
I want to know the standard/easiest way to add items to a parent?
Example: comment added to post
I would like this to happen in the ?show? view of post using a form that
is shown when the user clicks the ?add new? button/link. I would also
like validation on the child form with the validation errors appearing
in the post show? view.
Two problems are presented:
1) When the user clicks the
2008 Mar 04
2
Action Mailer throwing underscores on template name
I''ve recently run into a problem with one of my applications that
refuses to send emails using ActionMailer.
Looking at the log, it become obvious what''s happening, the system is
looking for templates with underscores at the end. Notice the
exception_notification_ .
For example:
ActionView::ActionViewError (No rhtml, rxml, rjs or delegate template
found for
2006 Aug 14
4
Updating a table with Ajax
I''ve been banging my head against the wall trying to update a table
(add/delete rows) using Ajax. It seems simple enough but just doesn''t work
for me. I can get it to work using DIVs instead of a table, but doing the
layout with DIVs is much more cumbersome and I know it works for others with
a table (though I haven''t been able to find an exact example code anywhere).
2006 Apr 09
12
Validating two models from one form
Howdy,
I''m working on my first RoR project, and I want to build a form. The
tricky thing is, this form needs to insert / update against two models,
each with their own validation rules. Unfortunately, I''m having an
incredible amount of difficulty with the error handling, specifically
the fields wrapped in <div class=''fieldWithErrors''></div>