Forum: Ruby on Rails Hash from Flex

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Kvark D. (Guest)
on 2007-03-12 18:36

Im new to rails and trying to pass a hash, from  my flex application to
my rails app.

My flex application calls a rails service

def updateScorecards(id, scorecard)

  puts "im in update scorecards2"
  puts pp scorecard

  @update_scorecard = Scorecard.find(id , :include => :kpis)
  puts pp @update_scorecard



class Scorecard < ActiveRecord::Base
  has_and_belongs_to_many :kpis

im using pp to write out the params, so we see what happens. Now to my
questions, how do i update my @update_scorecard with values from
scorecard param
@update_scorecard.update_attributes gives me unified_strings! error

Help appriciated!

Debug from this is:

im in update scorecards2
   {"name"=>"SecondScoreCArd", "id"=>2, "kpis"=>[], "view_id"=>1},
 @attributes={"name"=>"FirstScoreCard", "id"=>"1", "view_id"=>"1"},
  [#<Kpi:0x27948e4 @attributes={"name"=>"Generated.Kpi1",
"unit"=>"something", "id"=>"19", "description"=>nil}>, #<Kpi:0x27944fc
@attributes={"name"=>"Generated.Kpi2", "unit"=>"something", "id"=>"20",
Eden L. (Guest)
on 2007-03-12 19:49
(Received via mailing list)
update_attributes expects a proper hash.  You're handing it a
NamedObject.  I'm not exactly certain what that is, but can you
convert it into a hash and then pass it into update_attributes?

On Mar 13, 12:36 am, Kvark D. <removed_email_address@domain.invalid>
Kvark D. (Guest)
on 2007-03-12 22:01
Yo and thanks,

How do a proper hash look?
Eden L. (Guest)
on 2007-03-14 04:40
(Received via mailing list)
when you inspect it, it should look something like:

puts h.inspect
# => {"c"=>3, :a=>1, :b=>2}

not like

puts obj.inspect
# => #<RandomClass:0xb7c1f324 @inst={"c"=>3, :a=>1, :b=>2}>

Check the documentation for NamedObject and see if you can find some
way to have it return a hash.  If there is none, you can grab the
anonymous_object instance variable directly:

hash = named_obj.instance_eval { @anonymous_object }

... with the understanding that if NamedObject's implementation
changes in the future, your method might break.

On Mar 13, 4:01 am, Kvark D. <removed_email_address@domain.invalid>
This topic is locked and can not be replied to.