Skip to content

Commit

Permalink
fix will_paginate support
Browse files Browse the repository at this point in the history
git-svn-id: http://jnewland.com/svn/public/ruby/rails/plugins/resource_this@18 9b6b69f6-dd27-0410-8144-a0f3c56a22ea
  • Loading branch information
jnewland committed Sep 16, 2007
1 parent 37ab51f commit f08b34a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
33 changes: 22 additions & 11 deletions lib/resource_this.rb
Expand Up @@ -12,21 +12,32 @@ def resource_this(options = {})
class_name = options[:class_name] || singular_name.camelize
plural_name = singular_name.pluralize
will_paginate_index = options[:will_paginate] || false

module_eval <<-"end_eval", __FILE__, __LINE__
def index
if will_paginate_index

if will_paginate_index
module_eval <<-"end_eval", __FILE__, __LINE__
def index
@#{plural_name} = #{class_name}.paginate(:page => params[:page])
else
@#{plural_name} = #{class_name}.find(:all)
#TODO: add sorting customizable by subclassed controllers
respond_to do |format|
format.html
format.xml { render :xml => @#{plural_name} }
end
end
#TODO: add sorting customizable by subclassed controllers
respond_to do |format|
format.html
format.xml { render :xml => @#{plural_name} }
end_eval
else
module_eval <<-"end_eval", __FILE__, __LINE__
def index
@#{plural_name} = #{class_name}.find(:all)
#TODO: add sorting customizable by subclassed controllers
respond_to do |format|
format.html
format.xml { render :xml => @#{plural_name} }
end
end
end
end
module_eval <<-"end_eval", __FILE__, __LINE__
def show
@#{singular_name} = #{class_name}.find(params[:id])
Expand Down
1 change: 0 additions & 1 deletion test/resource_this_test.rb
Expand Up @@ -31,7 +31,6 @@ def setup

def test_should_get_index
get :index
puts @response.inspect
assert_response :success
assert assigns(:posts)
end
Expand Down

0 comments on commit f08b34a

Please sign in to comment.