Why can't show restaurant list?

后端 未结 3 1533
终归单人心
终归单人心 2020-12-12 08:21

I\'m trying to make some restaurant list. I associated two tables, and then write this code.

class Restaurant < ActiveRecord::Base
        has_many :resta         


        
相关标签:
3条回答
  • 2020-12-12 08:48

    because Restaurent has_many :restaurant_translations so you need to loop through

    restaurant.restaurant_translations.each do|res_trans|
    your code here
    end
    
    0 讨论(0)
  • 2020-12-12 08:53

    replace

     td = restaurant.restaurant_translations.restaurantname
    

    with

    td = restaurant.restaurant_translations.first.restaurantname
    

    this will help you

    0 讨论(0)
  • 2020-12-12 08:56

    Your restauration have multiple 'restaurant_translations'.

    Example, for first you can write td = restaurant.restaurant_translations.first.try(:restaurantname)

    0 讨论(0)
提交回复
热议问题