Custom module for ActionController no longer works in Rails 2.2

I am using some code for in place JS editing with validation, that
worked up until Rails 2.2. After upgrade, the method can’t be find, so
apparently its not overridge the right class or isn’t being included
as before. It is currently being included via a require statement in
environment.rb. The code is below. Any suggestions?

Brian Burridge
Agile Nomads
www.rubyrailsreview.com

– code –

module ActionController
module Macros
module CustomInPlaceEditing
def self.included(base)
base.extend(ClassMethods)
end

module ClassMethods
 def in_place_edit_with_validation_for(object, attribute)
  define_method("set_#{object}_#{attribute}") do
   klass = object.to_s.camelize.constantize
  @item = klass.find(params[:id])
  @item.send("#{attribute}=", params[:value])
   if @item.save
    render :update do |page|
     page.replace_html("#{object}_#{attribute}_#{params[:id]}

in_place_editor",
@item.send(attribute))
end
else
render :update do |page|
page.alert(@item.errors.full_messages.join(“\n”))
klass.query_cache.clear_query_cache if
klass.method_defined?:query_cache
@item.reload
page.replace_html("#{object}
#{attribute}_#{params[:id]}
_in_place_editor",
@item.send(attribute))
end
end
end
end
end
end
end
end

ActionController::Base.class_eval do
include ActionController::Macros::CustomInPlaceEditing
end

module ActionView
module Helpers
class InstanceTag
def to_content_tag(tag_name, options = {})
content_tag(tag_name, html_escape(value(object)), options)
end

end

end
end

On 4 Feb 2009, at 17:40, [email protected] wrote:

I am using some code for in place JS editing with validation, that
worked up until Rails 2.2. After upgrade, the method can’t be find, so
apparently its not overridge the right class or isn’t being included
as before. It is currently being included via a require statement in
environment.rb. The code is below. Any suggestions?

Maybe

?

Fred

That did the trick. Thanks Fred!!

Brian Burridge
Agile Nomads
www.rubyrailsreview.com

On Feb 4, 12:46 pm, Frederick C. [email protected]

An error backtrace would be really helpful.

Blog: http://random8.zenunit.com/
Learn rails: http://sensei.zenunit.com/

On 05/02/2009, at 4:40 AM, “[email protected][email protected]