As a user I want to have a receipt page so I can look at all the food_items with name and price for one party's item_order.
Right now I have a show.erb page in parties/show.erb. Below is my schema:
ActiveRecord::Schema.define(version: 20150826183516) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
create_table "food_items", force: :cascade do |t|
t.string "name"
t.integer "price"
t.string "allergens"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "item_orders", force: :cascade do |t|
t.integer "food_item_id"
t.integer "party_id"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "parties", force: :cascade do |t|
t.integer "table_number"
t.boolean "is_paid", default: false
t.datetime "created_at"
t.datetime "updated_at"
end
end
are showing. I want this to be my receipt page so I want to display food_item.name and food_item.price here as well. I have tried different syntax to display this like:
<%=@party.food_item.name%>
and several variations of that syntax.
The error I am getting is:
Undefined method 'food_item' if I use the above code or some variation of that. The above line of code is where it says the error is.
I realize that parties does not have a food_item name but I am trying to connect to it through the join table, is this an issue of syntax?
Is it possible that I can't link to those things through the join table and instead I should be in a file like item_orders/show.erb?
As a user I want to have a receipt page so I can look at all the food_items with name and price for one party's item_order.
Right now I have a show.erb page in parties/show.erb. Below is my schema:
And here is my ERD: https://docs.google.com/drawings/d/1cAGfMtF5nY6LI9E4OkUFaa2M-XMv4x8ovtsmkV7_aJc/edit
Right now I am displaying two things on my parties/show.erb:
Both
and
are showing. I want this to be my receipt page so I want to display food_item.name and food_item.price here as well. I have tried different syntax to display this like:
and several variations of that syntax.
The error I am getting is: Undefined method 'food_item' if I use the above code or some variation of that. The above line of code is where it says the error is.
I realize that parties does not have a food_item name but I am trying to connect to it through the join table, is this an issue of syntax?
Is it possible that I can't link to those things through the join table and instead I should be in a file like item_orders/show.erb?
Thanks
Bryan