1
leiz 2013-08-17 16:49:50 +08:00
# route.rb
match '/get_joke' to: 'jokes#getJokeByPageAndPageCount', via: 'get' # or post # jokes_controller.rb def getJokeByPageAndPageCount # do whatever you want respond_to do |format| format.xml { # send whatever you want } end end |
2
leiz 2013-08-17 16:52:07 +08:00
# jokes_controller.rb
def getJokeByPageAndPageCount # ... page = params[:page] page_count = params[:PageCount] |
3
rails3 2013-08-17 16:53:58 +08:00
@per_page = 10
users = User.paginate(:page => params[:page], :per_page => @per_page) users_count = User.all.count @page_count = users_count % @per_page == 0 ? users_count % @per_page : users_count % @per_page + 1 respond_to do |format| format.html # index.html.erb format.xml { render xml: {:page_count => @page_count, :users => users}.to_xml } end |
4
androidBrant OP |
5
androidBrant OP |
6
leiz 2013-08-17 18:52:49 +08:00
@androidBrant
这个问题和rails无关,你先去看看 html form, ajax |