I am developing an “issue tracker” app in Rails 3 but I am having trouble describing the relationship between an “Issue” and its “Status”. Each issue can only have one status – I’d like this to be a combo box in HTML – but clearly each status can be assigned to multiple issues. I started with “issue has one status” but then I ran into problems retrieving that status in the view. I assume this is correct, but I must need something else…
Share
You should be using
Issue belongs_to :statusandStatus has_many :issuesinstead.When you use a
has_oneassociation, Rails will look for the foreign keyissue_idin thestatusestable. This is not what you want. You want issues to point to statuses, not vice versa.