On Jul 19, 2006, at 6:35 PM, Ben Johnson wrote:
> I have a simple question, but can''t seem to figure this out.
>
> I added an in place editor field and didn''t like how it
didn''t use
> the save method. It uses the update_attribute method which does not
> run validation, etc. So I just added the method in my controller
> myself:
>
> def set_event_url
> begin
> @event = Event.find params[:id]
> @event.url = params[:value]
> @event.save
> render :text => @event.send(:url)
> rescue Exception => error
> render :text => error
> end
> end
>
> The problem is that if there is an error that is rescued it sets
> that field to the output of the error. What I''d like it to do is
> pop up a little javascript window like it does if an exception goes
> uncaught.
>
> Any ideas?
>
> Thanks for your help.
>
>
> Thank You,
> Ben Johnson
> E: bjohnson@contuitive.com
>
>
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
Better yet, is it possible to simply update a tag on the page and
keep the invalid value. Like the following:
def set_event_url
begin
@event = Event.find params[:id]
@event.url = params[:value]
@event.save
render :text => @event.send(:url)
rescue Exception => error
render :update do |page|
page.replace_html ''notices'', error
end
end
end
What happens there, is that the element on the page gets updated but
then the field value is replaced by the javascript that updates that
field. Any ideas how I can just keep the field value to the same
value that caused the error?
Thanks for the help.
Thank You,
Ben Johnson
E: bjohnson@contuitive.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060719/8124d9d2/attachment.html