我想通过引用/用户查看所有公司的列表
users_controller.rb:
def index
@companies = Company.all
respond_to do |format|
format.html # show.html.erb
format.json { render json: @companies }
end
end
用户/index.html.haml:
%div{:style => "margin:10px" }
%table{ :class => "table table-striped"}
%thead
%tr
%th
= t("Logo")
%th
= t("company_name")
%th
= t("website")
%th
%tbody
- @companies.each do |company|
%tr
%td
- if company.logo?
= link_to image_tag( company.logo.url, :width => "60", :height => "60"), company
- else
= link_to image_tag( "/lg.png", :width => "60", :height => "60"), company
%td
= link_to company.name, company_path
%td
- if company.website?
= link_to company.website, company.website
- else
= link_to company.name, company_path
%td
- if can? :read, company
= link_to '<i class="icon-info-sign icon-white"></i> '.html_safe + t('Show'), company, :class => 'btn btn-small btn-info'
- if can? :update, company
= link_to '<i class="icon-pencil icon-white"></i> '.html_safe + t('Edit'), edit_company_path(company), :class => 'btn btn-small btn-pencil'
- if can? :destroy, company
= link_to '<i class="icon-trash icon-white"></i> '.html_safe + t('Destroy'), company, confirm: t('Are you sure'), method: :delete, :class => 'btn btn-small btn-danger'
但是当链接出现错误时:
No route matches {:action=>"show", :controller=>"companies"}