我有兩個關係模型,用戶有很多設計。 設計具有回形針的「has_attached_file」。在回形針中的嵌套關系圖片網址
因此,當我爲圖像標記執行以下操作時,它工作正常。
@img_des = current_user.designs.first.img.url
但不能得到這個工作。
@img_des = current_user.designs.where(id: params[:id]).img.url
拋出以下錯誤
NoMethodError in DesignerController#show undefined method `design' for #<ActiveRecord::Relation::ActiveRecord_Relation_Design:0xb1ede48>
任何建議,主要是它必須是因爲我缺乏的軌道理解嵌套模型。
能否請您粘貼模式和控制器代碼這裏 –