N
N
nnobodyss abel2017-02-28 01:14:53
Blogs
nnobodyss abel, 2017-02-28 01:14:53

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)

/post_controller.rb
def post_params
    params.require(:post).permit(:title, :summary, :body, :image, :all_tags)
  end

/_form.html.erb
<div class="form-group">
  <%= f.label :all_tags %>
  <%= f.text_field :all_tags, class: 'form-control' %>
</div>

/tag.rb
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

/tagging.rb
class Tagging < ApplicationRecord
  belongs_to :post
  belongs_to :tag
end

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Satisfied IT, 2017-02-28
@nnobodyss

Tag_id not found in taggings table?

N
nnobodyss abel, 2017-02-28
@nnobodyss

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

accidentally put a space after tag:
)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question