I'm sorry my post was bad formatted. Now I'll repost with
right
justification.
I've 3 tables:
"monsters", "movements" and
"ana_movements". "monsters" contains
creatures who can have many movements (description is
'swim', 'walk',
'run', and so on) with differents values represented by
numeric
values. Numeric value is stored in "movements"
while description in
"ana_movements" so i can have same description
with different monster
without duplicate my data.
For example a goblin may run 12 feet and walk 9 feet. In my
table
I'll
have:
monsters
id: 49
name: goblin
movements
id: 37
value: 12
monster_id: 49
ana_movement_id: 546
id: 38
value: 9
monster_id: 49
ana_movement_id: 644
ana_movements:
id:546
description: run
id: 644
description: walk
I've a form who should update all my tables during update
but when i
save it updates monsters and my record in movements has no
ana_movement_id updated!
this is update in the controller
def update
monster = Monster.find(params[:id])
monster.attributes = params[:monster]
monster.movements.each{ |t| t.attributes =
params[:movement]
[t.id.to_s]}
if monster.valid? && monster.movements.all?(&:valid?)
monster.movements.each(&:save!)
redirect_to :action => 'show', :id => monster
else
render :action => 'edit'
end
end
can you help me?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Ruby on Rails" group.
To post to this group, send email to rubyonrails googlegroups.com
To unsubscribe from this group, send email to
rubyonrails-unsubscribe googlegroups.com
For more options, visit this group at http://gro
ups.google.com/group/rubyonrails
-~----------~----~----~----~------~----~------~--~---
|