Search code examples
mobilepaginationpartialkaminari

Rails3 Kaminari &Mobile Devices


I've implemented Kaminari in my views to paginate. Now I've implemented my app to detect mobile via the railscast instructions http://railscasts.com/episodes/199-mobile-devices.

Pagination works fine while not in mobile. When I switch to mobile which would be index.mobile.erb, I'm getting this error.


ActionView::MissingTemplate in Activities#index

Showing /home/jon/cny32/app/views/activities/index.mobile.erb where line #35 raised:

Missing partial kaminari/paginator with {:handlers=>[:erb, :builder, :arb, :coffee], :formats=>[:mobile], :locale=>[:en, :en]}. Searched in: * "/home/jon/cny32/app/views" * "/home/jon/.rvm/gems/ruby-1.9.2-p290/gems/activeadmin-0.4.2/app/views" * "/home/jon/.rvm/gems/ruby-1.9.2-p290/gems/devise-2.0.4/app/views" * "/home/jon/.rvm/gems/ruby-1.9.2-p290@global/gems/kaminari-0.13.0/app/views"

Extracted source (around line #35):

32: 33: 34:
35: <%= paginate @activities %> Rails.root: /home/jon/cny32

Application Trace | Framework Trace | Full Trace app/views/activities/index.mobile.erb:35:in _app_views_activities_index_mobile_erb___54960106_95964060' app/controllers/activities_controller.rb:8:inindex' Request

Parameters:

{"format"=>"mobile"} Show session dump

Show env dump

Response

Headers:

None


When I take out <%= paginate @activities %>, it works but only lists a page of 10 as specified in the controller, without pagination of course.

My goal is to have pagination on the normal view and pagination on the mobile devices.


Solution

  • Have this issue too. The obvious way to copy paste kaminari views from the gem to your app changing the extension to mobile. For this you need to:

    • bundle open kaminari
    • go to app/views in kaminari gem
    • copy kaminari folder from here and place it under your views folder
    • change partials extensions from html.erb to mobile.erb(haml and slim ones you can delete).

    But, again it is not the perfect way.