Forum: Ruby on Rails Custom module for ActionController no longer works in Rails 2.2

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
(Guest)
on 2009-02-04 19:41
(Received via mailing list)
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
Frederick C. (Guest)
on 2009-02-04 19:50
(Received via mailing list)
On 4 Feb 2009, at 17:40, removed_email_address@domain.invalid 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
http://www.spacevatican.org/2008/11/21/environment...
  ?

Fred
(Guest)
on 2009-02-04 23:08
(Received via mailing list)
That did the trick. Thanks Fred!!

Brian Burridge
Agile Nomads
www.rubyrailsreview.com

On Feb 4, 12:46 pm, Frederick C. <removed_email_address@domain.invalid>
Julian L. (Guest)
on 2009-02-05 02:31
(Received via mailing list)
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, "removed_email_address@domain.invalid" 
<removed_email_address@domain.invalid>
This topic is locked and can not be replied to.