How to add validation to in_place_editor

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 J.
E: [email protected]

On Jul 19, 2006, at 6:35 PM, Ben J. wrote:

  @event.url = params[:value]

uncaught.


Rails mailing list
[email protected]
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 J.
E: [email protected]