I am trying to learn RoR by creating my first application, the main inventory application. I tried searching, but could not find the correct syntax, so I thought I'd ask.
Here is my setup:
Model
class Item < ActiveRecord::Base
belongs_to :supplier
class Supplier < ActiveRecord::Base
has_many :items
Element controller
@items = Item.find_all_by_supplier_id '1'
This will return the data I want, but I was hoping to enter the provider name in the controller so that if the identifier does not match, it will still work correctly.
Hope enough information, thanks!
source
share