Associate two tables one-to-many in rhodes

I'm starting a new application in rhodes and I'm trying to associate two tables. I already tried doing what is suggested in but I guess there is something missing, because it is not working. This is what i did:

I have a Client table and a Photo table. A client can have many photos, but photos only one client. I added to my Photo.rb

belongs_to :client_id, 'Client' 

and added the following to client_controller:

photo = Photo.find(:first) # find the photo
photo.client_id = @client.object
redirect :action => :index

As said in the link above, but when I try to create a new user it doesn't work.

I also added:

@photo =

to the client_controller in new, and also added a field to enter some input to one of the fields in photo when creating a new Client. But again it doesn't work.

Do you have any suggestions? Thank you!


Associations (belongs_to, has_many, ...) in rhodes are useful only for sync operations. It indicates when to trigger a sync in certain objects, like its parent or childrens. For other purposes (manipulating object relations) you need to do it by yourself.

Need Your Help

Must jQuery be verbose?

jquery jquery-ui

I see a lot of jQuery code like this:

How to sort DropDownButton items?

c# xml winforms

I populate DropDownButton by xml nodes