ruby on rails - how to get the reference? -
please solve problem.
there table users:
id :integer, autoincrement name :string gender_id :integer
there table genders:
id :integer, autoincrement gender_name :string
model user:
class user < activerecord::base belongs_to :gender end
model gender:
class gender < activerecord::base has_many :users end
i need gendername. try so:
<% @users.each |user| %> <div class="col-xs-6"><%= user.name %></div> <div class="col-xs-2"><%= user.gender_id %></div> <% end %>
the result output number, need gendername
my column 'gender_id' contain 0 value. problem has been
Comments
Post a Comment