I am trying to make kaminari ajax button work, but I have one problem which seems to be causing error and stopping from kaminari to work.
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
and it returns me with error...
undefined method `each' for nil:NilClass
Below is what I have in my view file. 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"
This is the view file for the _works.html.slim
- @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
I am guessing those two @works... and render :layout =>application.... can not co-exist??
How could I fix this??? Thank you in advance!
note: render :layout => 'application' loads header and rest of the page.
my trace log
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'