I am getting this error , how to solve this relation error
i have a model called property.rb
class Property < ActiveRecord::Base
belongs_to :rm
belongs_to :category
end
also i have category.rb
class Category < ActiveRecord::Base
has_many :rms,dependent: :destroy
has_many :properties,dependent: :destroy
end
my RM(relationship Manager) model is
class Rm < ActiveRecord::Base
acts_as :user
belongs_to :category
has_many :properties
end
in my controller i listing properties like this
class Rms::PropertiesController < ApplicationController
before_filter :authenticate_user!
before_action :set_property, only: [:show, :edit, :update, :destroy]
def index
@properties = Property.all
end
def property_params
params.require(:property).permit(:seller_name,:rm_id,:category_id,:property_type_id,:seller_email,:seller_phone,:property_name)
end
end
in my view page i am listing the property added by RM in index.html.erb
<% @properties.each do |property| %>
<tr>
<td><%= property.seller_name %></td>
<td><%= property.seller_email %></td>
<td><%= property.seller_phone %></td>
<td><%= property.category.name %></td>
<td><%= property.property_name %></td>
<% end %>
Aucun commentaire:
Enregistrer un commentaire