has_and_belongs_to_manyのアソシエーションがうまくいきません。
model
ruby
1##station.rb 2class Station < ApplicationRecord 3 has_and_belongs_to_many :cleaner_profiles 4end
ruby
1##cleaner_profile.rb 2class CleanerProfile < ApplicationRecord 3 belongs_to :cleaner 4 has_and_belongs_to_many :stations 5end
ruby
1##cleaner_profiles_station.rb 2class CleanerProfilesStation < ApplicationRecord 3end
controller
ruby
1##station_controller.rb 2 def index 3 @stations = Station.all 4 end
view
ruby
1##views/stations/index.html.erb 2<ul> 3<% @stations.cleaner_profiles.each do |test| %> 4 <li><%= test.id %></li> 5<% end %> 6</ul> 7
stationからcleaner_profileの情報がうまく取得できません。
スネークケースの記述の仕方の問題でしょうか?
お詳しい方ご教授お願い致します。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/01/09 02:59
2018/01/09 08:52