Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #964: scaffold_paginator.diff

File scaffold_paginator.diff, 1.1 kB (added by mortonda@dgrmm.net, 4 years ago)

apply to: railties/lib/rails_generator/generators/components/scaffold/templates/

  • controller.rb

    old new  
    11class <%= controller_class_name %>Controller < ApplicationController 
     2  model :<%= singular_name %> 
     3 
    24<% unless suffix -%> 
    35  def index 
    46    list 
     
    1214 
    1315<% end -%> 
    1416  def list<%= suffix %> 
    15     @<%= plural_name %> = <%= model_name %>.find_all 
     17    @<%= singular_name %>_pages, @<%= plural_name %> = paginate :<%= singular_name %>, :per_page => 10 
    1618  end 
    1719 
    1820  def show<%= suffix %> 
  • view_list.rhtml

    old new  
    11<h1>Listing <%= plural_name %></h1> 
    2  
     2<%%= link_to "Previous page", { :page => @<%= singular_name %>_pages.current.previous } if @<%= singular_name %>_pages.current.previous %> 
     3<%%= link_to "Next page", { :page => @<%= singular_name %>_pages.current.next } if @<%= singular_name %>_pages.current.next %>  
    34<table> 
    45  <tr> 
    56<%% for column in <%= model_name %>.content_columns %>