.each循环添加在底部添加另一个数组

时间:2014-01-24 09:32:42

标签: ruby-on-rails view render

当我尝试渲染列表分页作业时,尽管包含了所有这些项目的数组。发生了什么事? http://take.ms/9HtCa

jobs_controller.rb

def index
  @joblist = Job.page(params[:page]).per(20) 
   render 'jobs/index'
end

index.html.haml

.row-fluid
  .span8.hidden-desktop
    =render 'job'

  .span4
    .center
      .add-job
        =link_to "добавить вакансию", new_job_path

_job.html.haml

%span
  =@joblist.each do |job|
    %ul
      .job-item
        %span
          .fl-l
            =job.title
          .fl-r
            =succeed ',' do
              =Country.find_by_id(job.country_id).name
            =City.find_by_id(job.city_id).name
          %br
        %span
          .fl-l
            =job.jobtype
        %br

  =paginate @joblist

2 个答案:

答案 0 :(得分:1)

=之前移除@joblist.each。它显示由表达式返回的值,每个都返回它迭代的数组。

答案 1 :(得分:1)

=应为-

=呈现输出,但-评估ruby表达式。

Ruby Evaluation in Haml