Ilan Berci wrote: > Pål Bergström wrote: > Controllers have nothing to do with models, although best practices > suggests having a controller per model. > > A controller has visibility into all your models if it needs to.. > > Please show us your relations that you wrote in your models and the > controller code used to access them and then we may be better prepared > to assist you > > ilan
class Basket < ActiveRecord::Base has_many :products end class Product < ActiveRecord::Base has_many :product_photos belongs_to :basket def self.created_at created_at.strftime("%Y-%m-%d") end end class ShopController < ApplicationController def basket @mybasket = Basket.find_all_by_session_id(session[:basket_has_items]) end end <% for item in @mybasket %> <%= item.product.name %> <% end %> I get @mybasket. But I can't access product info. It says "undefined method `product'" -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---