Answer the question
In order to leave comments, you need to log in
SQLite3::SQLException: no such column: taggings.tag_id:?
mistake
SQLite3::SQLException: no such column: taggings.tag_id: SELECT "tags".* FROM "tags" INNER JOIN "taggings" ON "tags"."id" = "taggings"."tag_id" WHERE "taggings"."post_id" = ?
Extracted source (around line #11):
9
10 def all_tags
11 self.tags.map(&:name.to_proc).join(', ')
12 end
13
14 def all_tags=(names)
def post_params
params.require(:post).permit(:title, :summary, :body, :image, :all_tags)
end
<div class="form-group">
<%= f.label :all_tags %>
<%= f.text_field :all_tags, class: 'form-control' %>
</div>
class Tag < ApplicationRecord
has_many :taggings
has_many :posts, through: :taggings
def self.counts
self.select("name, count(taggings.tag_id) as count").joins(:taggings).group("name, taggings.tag_id")
end
end
class Tagging < ApplicationRecord
belongs_to :post
belongs_to :tag
end
Answer the question
In order to leave comments, you need to log in
Thank you all, I was flipping through the logs - I found an error:
when generating a model
$ rails g model tagging post:belongs_to tag: belongs_to
tag:
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question