#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2009
    Posts
    12
    Rep Power
    0

    NoMethodError (undefined method `save' for #<HashWithIndifferentAccess:0x1032677e0>


    Hello-
    I'm sending an object to RubyAMF from Actionscript, and getting an unexpected error that I can't figure out. Here's what it looks like:

    Code:
    Processing AmfsearchesController#save (for 127.0.0.1 at 2009-11-23 13:46:26) [POST]
      Parameters: {0=>{"city"=>"southeast alaska", "active"=>false}}
    
    NoMethodError (undefined method `save' for #<HashWithIndifferentAccess:0x1032677e0>):
      app/controllers/amfsearches_controller.rb:25:in `save'
      app/controllers/amfsearches_controller.rb:21:in `save'
      vendor/plugins/rubyamf/app/actions.rb:139:in `invoke'
      vendor/plugins/rubyamf/app/actions.rb:86:in `run'
      vendor/plugins/rubyamf/app/filters.rb:68:in `run'
      vendor/plugins/rubyamf/app/filters.rb:68:in `run'
      vendor/plugins/rubyamf/app/filters.rb:65:in `each'
      vendor/plugins/rubyamf/app/filters.rb:65:in `run'
      vendor/plugins/rubyamf/app/filters.rb:63:in `upto'
      vendor/plugins/rubyamf/app/filters.rb:63:in `run'
      vendor/plugins/rubyamf/app/filters.rb:12:in `run'
      vendor/plugins/rubyamf/app/filters.rb:11:in `each'
      vendor/plugins/rubyamf/app/filters.rb:11:in `run'
      vendor/plugins/rubyamf/app/rails_gateway.rb:28:in `service'
      app/controllers/rubyamf_controller.rb:16:in `gateway'
    So at the beginning there you can see the parameters are there, but it looks like it can' convert the object. Here's the 'save' method:

    Code:
      # saves new or updates existing Amfsearch
      # expect params[0] to be incoming Amfsearch
      def save
        respond_to do |format|
          format.amf do
            @amfsearch = params[0]
    
            if @amfsearch.save
              render :amf => @amfsearch
            else
              render :amf => FaultObject.new(@amfsearch.errors.full_messages.join('\n'))
            end
          end
        end
      end
    Any ideas? I greatly appreciate it.
    Thanks!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2004
    Location
    Constant Limbo
    Posts
    989
    Rep Power
    363
    Have you defined save in HashWithIndifferentAccess?
    True happiness is not getting what you want, it's wanting what you've already got.

    My Blog
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2009
    Posts
    12
    Rep Power
    0
    Isn't HashWithIndifferentAccess a type?
    I'm not sure what you mean. I've looked a a bunch of examples and haven't seen anything that sounds like whatever you're talking about.
    Example?
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2004
    Location
    Constant Limbo
    Posts
    989
    Rep Power
    363
    Code:
    irb(main):001:0> class Foo; end
    => nil
    irb(main):002:0> f = Foo.new
    => #<Foo:0x38dbb4>
    irb(main):003:0> f.save
    NoMethodError: undefined method `save' for #<Foo:0x38dbb4>
            from (irb):3
            from :0
    irb(main):004:0>
    The error you are seeing is telling you that you are trying to invoke a method on an object that does not support it. See above for details.
    From your context, you are either expecting whatever you are calling save on to be something other than HashWithIndifferentAccess or you are expecting HashWithIndifferentAccess to have a method save defined, which it does not.
    True happiness is not getting what you want, it's wanting what you've already got.

    My Blog

IMN logo majestic logo threadwatch logo seochat tools logo