0
我有以下代碼行似乎工作正常。活動記錄關聯錯誤 - 未定義方法
<% current_user.blockedshows.map(&:tvshows).each_with_index do |blocked, index| %>
然而,當我把它在blocked.title
和image_tag(blocked.image)
,(以下全碼),我收到以下錯誤:undefined method title for <ActiveRecord::Associations::CollectionProxy::ActiveRecord_Associations_CollectionProxy_Tvshow:0x007fd4e24b9448>
查看
<%= blocked.title %>
<%= image_tag(blocked.image) %> </br>
Tweets containing the following keywords will be removed from your timeline: </br>
<%@keywords = blocked.phrases.map(&:text) %>
<%[email protected] %> </br>
Blockedshow型號
class Blockedshow < ActiveRecord::Base
has_many :tvshows
belongs_to :user
end
Tvshow模型
class Tvshow < ActiveRecord::Base
has_many :phrases
belongs_to :blockedshow
end
Tvshow表
class CreateTvShows < ActiveRecord::Migration
def change
create_table :tvshows do |t|
t.string :title
t.string :image
t.timestamps
end
end
end
謝謝!現在我得到錯誤'SQLite3 :: SQLException:沒有這樣的列:tvshows.blockedshow_id:SELECT「tvshows」。* FROM「tvshows」WHERE「tvshows」。「blockedshow_id」=?' – ashleye6
沒關係,我修復了這個表現在工作。 – ashleye6