-3
我有三个模型作为followings.check出wheather我有关联他们correctly.sorry.am新轨道显示数据,其中指定==“经理”
class Designation < ActiveRecord::Base
has_many :employes
end
class Employe < ActiveRecord::Base
belongs_to :designation
has_many :branch
end
class Branch < ActiveRecord::Base
belongs_to :employe
end
在我的雇工形式,我有添加一个选择框来选择指定。并显示在雇佣指数页面...现在的问题是我想显示雇员的名称,他们的指定作为经理在我的分支模型..如何做到这一点..... 这是我的分支控制器
def index
@branches = Branch.all
end
def show
end
def new
@branch = Branch.new
end
,这为m Y分支器查看
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>Branch name</th>
<th>Branch address</th>
<th>Phoneno</th>
<th>Mangers name</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<% @branches.each do |branch| %>
<tr>
<td><%= branch.branch_name %></td>
<td><%= branch.branch_address %></td>
<td><%= branch.phoneno %></td>
<td><%= branch.employe_id %></td>
</div>
<td></td>
<td>
<% if branch.is_active == true %>
<%= link_to " Active ",edit_branch_path(branch),class:
"btn btn-warning"%>
<%else%><%= link_to
"Inactive",edit_branch_path(branch),class: "btn
btn-warning"%>
<%end%>
</td>
<td>
<div class="btn-group">
<span class=" btn btn-info dropdown-toggle"
data-toggle="dropdown" href="#menu1">Action
<b class="caret"></b>
</span>
<ul class="dropdown-menu">
<li><%= link_to 'Edit', edit_branch_path(branch) %></li>
<li><%= link_to 'Destroy', branch, method: :delete, data: {
confirm: 'Are you sure?' } %></li>
</ul>
</li>
</td>
</div>
</tr>
<% end %>
</tbody>
</table>
Mysql2 ::错误:未知列'whereations'中的'designations.employe_id':SELECT'designations'。* FROM'designations' WHERE'designations'.'employe_id' = 1 LIMIT 1 am getting following error bro。 – aaquib
可能在创建workers scaffold的同时我添加了指定:references ...是这个原因,现在该怎么办?plz帮助我 – aaquib
您是否已将employe_id添加到指定中? – puneet18