Javascript 渲染:布局=>';应用程序';与卡米纳里的冲突
我试图使kaminari ajax按钮工作,但我有一个问题,似乎是导致错误和停止从kaminari工作 index.controller.rbJavascript 渲染:布局=>';应用程序';与卡米纳里的冲突,javascript,ruby-on-rails,ajax,kaminari,slim-lang,Javascript,Ruby On Rails,Ajax,Kaminari,Slim Lang,我试图使kaminari ajax按钮工作,但我有一个问题,似乎是导致错误和停止从kaminari工作 index.controller.rb def index @works = Work.page params[:page].per(10) respond_to do |format| format.html format.js end render :layout => 'application' end 它返回给我一
def index
@works = Work.page params[:page].per(10)
respond_to do |format|
format.html
format.js
end
render :layout => 'application'
end
它返回给我一个错误
undefined method `each' for nil:NilClass
下面是我的视图文件中的内容。
root.html.slim
= render "layouts/alert"
.mainWrapper.cf
#workWrapper.cf
#intro
h1
| foriio is a platform for creators.
br
| We aim to bring portfolio to all creators.
p
| We think, it shouldn’t matter whether you can code or not.
br
| Nor whether you know how to use photoshop.
br
| So we aim to make things a lot easier for creators to make portfolio.
#howto
ul
li.one-third.column
= image_tag "step1.png"
| 1. Sign in with your facebook account
li.one-third.column
= image_tag "step2.png"
| 2. Submit your work, and your portfolio is now ready!
li.one-third.column
= image_tag "step3.png"
| 3. Tag collaborators such as Stylists, Make up artists, etc.
br
| Or tag yourself if you were involved!
h2.recentTitle Recent uploads
ul#works
= render :partial => "works"
- @works.each do | work |
= link_to work
li.works
span.thumb
= work_image_of work
h4 = link_to work.title, work, thumb:true
p.pull-left
small
= work.collaborators.count.to_s
| collaborators
p.pull-right
small
= link_to 'Edit', edit_work_path(work) if can? :update, work
|
= link_to 'Destroy', work, data: {:confirm => 'Are you sure?'}, :method => :delete if can? :delete, work
= paginate @works, remote: true
这是_works.html.slim的视图文件
= render "layouts/alert"
.mainWrapper.cf
#workWrapper.cf
#intro
h1
| foriio is a platform for creators.
br
| We aim to bring portfolio to all creators.
p
| We think, it shouldn’t matter whether you can code or not.
br
| Nor whether you know how to use photoshop.
br
| So we aim to make things a lot easier for creators to make portfolio.
#howto
ul
li.one-third.column
= image_tag "step1.png"
| 1. Sign in with your facebook account
li.one-third.column
= image_tag "step2.png"
| 2. Submit your work, and your portfolio is now ready!
li.one-third.column
= image_tag "step3.png"
| 3. Tag collaborators such as Stylists, Make up artists, etc.
br
| Or tag yourself if you were involved!
h2.recentTitle Recent uploads
ul#works
= render :partial => "works"
- @works.each do | work |
= link_to work
li.works
span.thumb
= work_image_of work
h4 = link_to work.title, work, thumb:true
p.pull-left
small
= work.collaborators.count.to_s
| collaborators
p.pull-right
small
= link_to 'Edit', edit_work_path(work) if can? :update, work
|
= link_to 'Destroy', work, data: {:confirm => 'Are you sure?'}, :method => :delete if can? :delete, work
= paginate @works, remote: true
我猜这两个@works。。。和render:layout=>application。。。。不能共存
我怎样才能解决这个问题???
提前谢谢你
注意:render:layout=>“应用程序” 加载页眉和页面的其余部分 我的跟踪日志
Processing by IndexController#root as HTML
Rendered layouts/_alert.html.slim (0.4ms)
Rendered index/_works.html.slim (9.9ms)
Rendered index/root.html.slim (22.9ms)
Completed 500 Internal Server Error in 32ms
NoMethodError - undefined method `each' for nil:NilClass:
app/views/index/_works.html.slim:1:in `_app_views_index__works_html_slim___3157568365315559456_70136848436740'
actionview (4.1.5) lib/action_view/template.rb:145:in `block in render'
你用的是partials吗?这看起来不像是kaminari的问题,它看起来像是如果您使用:@在由ajax呈现的分部或页面中工作,您需要让分部知道这一点。请张贴查看代码。您能提供完整的跟踪日志吗?谢谢@我添加了跟踪日志@HirohitoYamada我指的是ruby跟踪日志,可以在控制台/logfile@МаъСаъъъopps中看到,对不起。。我补充说。