我收到以下错误,似乎无法解决如何解决问题
undefined method `menu_attribute_value' for #<MenuAttribute:0x007f969a30c270>
%section.block-list
- @attr.each do |attrs, values|
%header= attrs
%ul
- values.each do |value|
%li
%input{:checked => '', name: value.id, type: 'radio', value: value, id: value}
%label{:for => value}= value.menu_attribute_value
控制器
# GET /menu_items/1
# GET /menu_items/1.json
def show
@menu_item = MenuItem.find(params[:id])
@menu_item_attr = @menu_item.menu_attributes
@attr = @menu_item_attr.group_by { |a| a.name }
respond_to do |format|
format.html # show.html.haml
format.json { render json: @menu_item }
end
end
MenuAttribute Model
class MenuAttribute < ActiveRecord::Base
# attr_accessible :name
belongs_to :menu_item
belongs_to :venue
def menu_attribute_params
params.require(:menu_attribute).permit(:name)
end
end
MenuItemAttribute Model
class MenuAttributesItems < ActiveRecord::Base
# attr_accessible :menu_attribute_id, :menu_attribute_value, :menu_item_id, :venue_id
belongs_to :menu_attribute
belongs_to :menu_item
belongs_to :venue
def menu_attributes_items_params
params.require(:menu_attributes_items).permit(:menu_attribute_value)
end
end