Sha256: c4c8aa9e84cb806d00ee6b4117995f29c40832026c5c8307523ee6692ee11692

Contents?: true

Size: 1.32 KB

Versions: 1

Compression:

Stored size: 1.32 KB

Contents

class Mg::RalliesController < Mg
 
  def index
    @page = !params[:page].nil? ? params[:page].to_i : 1
    @convert = Convert.find(params[:convert_id]) if !params[:convert_id].nil?
 
    if @convert
      @rallies = @convert.rallies.find(:all, :conditions => { }, :order => "created_at DESC", :limit => 100, :offset => ( @page - 1 ) * 100 )
    else
      @rallies = Rally.find(:all, :conditions => { }, :order => "created_at DESC", :limit => 100, :offset => ( @page - 1 ) * 100 )
    end
    
    respond_to do |format|
      format.html { }
    end
  end
  
  def new_rallies
    recent_rally = params[:recent_rally].to_i
    convert = Convert.find(params[:convert_id].to_i) unless params[:convert_id].blank?
    
    if convert
      @rallies = convert.rallies.find(:all, :conditions => [ 'id > ?', recent_rally ], :order => "id DESC" )
    else
      @rallies = Rally.find(:all, :conditions => [ 'id > ?', recent_rally ], :order => "id DESC" )
    end
    
    if @rallies.count > 0
      render :json => { :success => true,
                      :result => render_to_string(:partial => 'mg/rallies/rallies', :locals => { :rallies => @rallies } ),
                      :recent_rally_id => @rallies.first.id }
    else
      render :json => { :success => false }
    end
    
  end
  
  def show
    @rally = Rally.find(params[:id])
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mountain-goat-1.0.0 lib/mountain-goat/controllers/mg/rallies_controller.rb