Redhames, got it thanks! Have tested this and now seems to work. Even
the type field is put in automatically when the form submits.
Is this normal that the type field saves as “CitySuggestion” and
“BusinessSuggestion” respectively? Can I change the way it saves, as
“city” or “business”, instead?
Can we talk about the design factor for this. I realise the potential
of STI’s now. However, lets assume this scenario.
Ive got user and product. A user can leave comments, like, upload
products. These are called interactions. On a product page, I need to
display the product and all comments for the product. I also have a
user page with a section that displays all the users recent
interactions, sorted by the created_at date.
I was thinking of using an STI for this, with something like:
class Interaction < ActiveRecord::Base
attr_accessible :user_id, :product_id, :comment, :ip_address, :type
class Comment < Suggestion
attr_accessible :user_id, :product_id, :comment
class Upload < Suggestion
attr_accessible :user_id, :product_id, :ip_address
class Like < Suggestion
attr_accessible :user_id, :product_id
However, I was also considering using a polymorphic behavior. Or in
your opinion, would an STI be more suitable for this?