nnobodyss
@nnobodyss
junior

SQLite3::SQLException: no such column: taggings.tag_id:?

ошибка
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
  • Вопрос задан
  • 318 просмотров
Решения вопроса 2
В таблице taggings не найдено tag_id?
Ответ написан
Комментировать
Выполнить миграцию, если забыл
Ответ написан
Комментировать
Пригласить эксперта
Ответы на вопрос 1
nnobodyss
@nnobodyss Автор вопроса
junior
всем спасибо, листал логи -- нашел ошибку:
при генерации модели
$ rails g model tagging post:belongs_to tag: belongs_to

случайно поставил пробел после tag:
)
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы