Find by association

First off, I'm an extreme rails newbie trying to find my programming legs again after years of not developing.

So, I have a User model which has_many characters. And a character model that belongs_to the user.

In my Character_controller, I'm attempting to do a find by association to get a list of all characters assocaited with the user.

@user = session[:uid] @characters = @user.characters.find_all_by_user(@user.id) (or something similar, I don't have the code in front of me)

When I execute the action, I get an error message stating that there is no user_id field in the character table, which is accurate, but I thought the association took care of that. I think I'm missing a step somewhere.

When I execute the action, I get an error message stating that there is no user_id field in the character table, which is accurate, but I thought the association took care of that. I think I'm missing a step somewhere.

You need to create the foreign key (user_id, in this case) in your migration yourself, the association does not automatically do that for you.