Hi!
I’m new to this group and new to RoR. Because I want to learn RoR I
defined a project for myself for learning purposes. So I think this
will be my first question of quite a few that will follow.
I try to update multipe tables after sending a form. My form is very
basic by now and has a title and a short description and a long
description. Idea is that there will be multiple description fields
later. So the long desc is in another table. I set up all this foreign
key, belongs_to and has_many stuff and I’m now able to create a new
document in which all data is stored in the right tables. But I’m not
able to update it.
This is how my update method looks right now:
def update
@document = Document.find(params[:id])
@text_items = TextItem.find(:all)
@text_items.each { |ti| @document.text_items << ti }
if @document.update_attributes(params[:document])
flash[:notice] = ‘Document was successfully updated.’
redirect_to :action => ‘show’, :id => @document
else
render :action => ‘edit’
end
end
I did not get an error but the data from my text_items will not be
saved. I read through my books now multiple times and searched the
internet but I did not find a solution.
Can somenone please give me a hint? Thanks.
Regards,
Stefan