I'm working on a website for managing dog kennels, and have models such as Owner and Patient. I'm trying to implement a list that will be generated twice a day (AM/PM) with feeding information for that shift. A dog can be labeled NPO, which means that they are not listed for feeding that shift. The logic is:
for each Patient |patient|
if patient !NPO
add to feed list
end
end
I'm confused on how to implement it within rails. I generated a scaffold for feed_list
, and gave it the quality: has_many :patients
. I also gave patient
the quality: belongs_to :feed_list
. I'm assuming that my code is supposed to go /views/feed_lists/new.html.erb
, but I'm not sure. I tried:
<%= Patient.each do |p| %>
<%= if p.NPO != true %>
how do I add to feed list?
<%= end %>
<%= end %>
my Patient.rb
class Patient < ActiveRecord::Base
belongs_to :owner, :feed_list
validates :name, presence: true, length: { maximum: 50 }
has_many :stays
end
feed_list.rb
class FeedList < ActiveRecord::Base
has_many :patients
end