If this is not a legacy table I would recommend adding the ID column and make it your primary key. It will simplify things. You could still have a unique key on article and user that you can use to your hearts content. If that's the way you are going I would add an index on those 2 columns since I'm guessing you would be doing most of your DB access using those fields.
One benefit of adding the ID would show up if you create a child table that depends on FAVORITES. You would add a field called 'favority_id' on the child table and use 'has_*' and 'belongs_to' and everything would be handled for you by Rails. pepe On Apr 21, 10:34 pm, Lee Smith <[email protected]> wrote: > I've got a model, Favorite, that I'm trying to remove from the > database by calling the destroy method on it. What's noteworthy about > this model is that it doesn't have an id column. The unique index on > the Favorites table is a both the user_id and the article_id. A > favorite belongs to a user and an article. > > So in my destroy method of my Favorites Controller, I first retrieve > the favorite to delete: > > favorite = Favorite.find_by_article_id_and_user_id(params[:id], > @current_user.id) > > Then I call favorite.destroy and I notice this in the log: > > "DELETE FROM favorites where id = NULL" > > So the delete doesn't actually work. What gives? Do I HAVE to have > an id column in the favorites table? Thanks for any help. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group > athttp://groups.google.com/group/rubyonrails-talk?hl=en. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

