Almog Friedman wrote:
> heres the log hope it'll help:
> 
Processing FactionsController#create (for 127.0.0.1 at 2010-09-23
21:46:39)
[POST]
  Parameters: {"commit"=>"Create",
"authenticity_token"=>"1f1aa67b947f0e23dc19aad8debc1e63b6df002c",
"faction"=>{"name"=>"asdasd", "name_plural"=>"asdasd",
"description"=>"asdasdasd"}}

FactionContent Create (7.4ms)   INSERT INTO `faction_contents`
(`created_at`, `updated_at`, `english`) VALUES('2010-09-23 19:46:39',
'2010-09-23 19:46:39', NULL)

no values for 'english' in any of the inserts

I think you're over-complicating things...

In factions_controller.rb:

def create
  # just grab the hash for the model being saved
  hash = params[:faction]
  # do the string to content record id magic
  hashnew = save_ids(hash)
  # save a new Faction record
  Faction.create(hashnew)
  # find the one just saved
  @faction = Faction.find(:last, :order => 'id')
end

And wherever you have this stored:

def save_ids(arguments)
  # saving the content is table agnostic, don't need that parameter

  # new empty hash to return
  ret = Hash.new
  # for the incoming arguments hash
  arguments.each_pair { |key,value|
    # store each value in Contents
    Content.create(:english => value)
    # find the record just written
    content = Content.find(:last, :order => 'id')
    # replace the string just stored with a stringified id from Contents
    ret[key] = content.id.to_s
  }
  # return our new hash
  return ret
end

worked for me...
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to