I have a strange SQLException with my association.
I`ve created a join table using migration:
create_join_table :reviews, :posts
So there is a table in db posts_reviews
In both models I`ve configured relations:
class Post < ActiveRecord::Base
has_and_belongs_to_many :reviews
class Review < ActiveRecord::Base
has_and_belongs_to_many :posts
But when I run this command Post.find(X).reviews << Review.find(Y)
The result is:
SQLite3::SQLException: no such table: : INSERT INTO "" ("post_id", "review_id") VALUES (?, ?)
So the join table name is empty.
Aucun commentaire:
Enregistrer un commentaire