Mongoid update_attributes issues

hi,

i have two model CHALLENGE and TASK, CHALLENGE embeds_many :tasks and
TASK
embbeded_in :challenge
when i updating particular task attrubutes then it working
@ch_ts_update.tasks.where(:name => params[:name]).update(:is_complete =>
1)

when trying to update whole task using challenge params
@challenge.update_attributes(params[:challenge])

instead of updating existing tasks it creating new tasks. I think, i m
missing some configuration in mangoid.yml

thanks in advance!!!
Pravin M.

hey,

is there any help, my code of challenge and task model and controller
and
mongoid.yaml is below

class Challenge
include Mongoid::Document
include Mongoid::Timestamps::Created
include Mongoid::Timestamps::Updated

TASKS

embeds_many :tasks
accepts_nested_attributes_for :tasks

field :title, :type=>String
field :description, :type=>String

end

class Task
include Mongoid::Document

name of task

field :name, :type => Hash

score translates to Point on UI

field :score_by

score translates to Point on UI

field :score

task status

field :is_complete, :type => Integer, :default => 0

embedded_in :challenge
end

def update

@challenge = Challenge.find(params[:id])
#raise ch = params[:challenge].inspect
if @challenge.update_attributes(params[:challenge])
  redirect_to :action => 'index', :id => @challenge
else
  render :action => edit
end

end

mongoid.yaml

defaults: &defaults
allow_dynamic_fields: true
parameterize_keys: true
persist_in_safe_mode: true
raise_not_found_error: true
reconnect_time: 3
use_object_ids: false

development:

host: localhost
database: xxxxx_development

test:
host: localhost
database: xxxxx_test

set these environment variables on your prod server

production:
host: localhost
port: 27017
database: xxxxx_development
#host: <%= ENV[‘MONGOID_HOST’] %>
#port: <%= ENV[‘MONGOID_PORT’] %>
#username: <%= ENV[‘MONGOID_USERNAME’] %>
#password: <%= ENV[‘MONGOID_PASSWORD’] %>
#database: <%= ENV[‘MONGOID_DATABASE’] %>

slaves:

- host: slave1.local

port: 27018

- host: slave2.local

port: 27019

---------- Forwarded message ----------
From: Pravin M. [email protected]
Date: 26 November 2011 18:02
Subject: mongoid update_attributes issues
To: [email protected]

hi,

i have two model CHALLENGE and TASK, CHALLENGE embeds_many :tasks and
TASK
embbeded_in :challenge
when i updating particular task attrubutes then it working
@ch_ts_update.tasks.where(:name => params[:name]).update(:is_complete =>
1)

when trying to update whole task using challenge params
@challenge.update_attributes(params[:challenge])

instead of updating existing tasks it creating new tasks. I think, i m
missing some configuration in mangoid.yml

thanks in advance!!!
Pravin M.