Class: Mg::ConvertsController
- Defined in:
- lib/mountain-goat/controllers/mg/converts_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /converts POST /converts.xml.
-
#destroy ⇒ Object
DELETE /converts/1 DELETE /converts/1.xml.
-
#edit ⇒ Object
GET /converts/1/edit.
-
#index ⇒ Object
GET /converts GET /converts.xml.
-
#new ⇒ Object
GET /converts/new GET /converts/new.xml.
-
#show ⇒ Object
GET /converts/1 GET /converts/1.xml.
-
#update ⇒ Object
PUT /converts/1 PUT /converts/1.xml.
Instance Method Details
#create ⇒ Object
POST /converts POST /converts.xml
73 74 75 76 77 78 79 80 81 82 |
# File 'lib/mountain-goat/controllers/mg/converts_controller.rb', line 73 def create @convert = Mg::Convert.new(params[:convert]) if @convert.save flash[:notice] = 'Convert was successfully created.' redirect_to mg_convert_url :id => @convert.id else render :action => "new" end end |
#destroy ⇒ Object
DELETE /converts/1 DELETE /converts/1.xml
99 100 101 102 103 104 105 106 107 |
# File 'lib/mountain-goat/controllers/mg/converts_controller.rb', line 99 def destroy @convert = Mg::Convert.find(params[:id]) @convert.destroy respond_to do |format| format.html { redirect_to mg_converts_url } format.xml { head :ok } end end |
#edit ⇒ Object
GET /converts/1/edit
67 68 69 |
# File 'lib/mountain-goat/controllers/mg/converts_controller.rb', line 67 def edit @convert = Convert.find(params[:id]) end |
#index ⇒ Object
GET /converts GET /converts.xml
6 7 8 9 10 11 12 13 |
# File 'lib/mountain-goat/controllers/mg/converts_controller.rb', line 6 def index @converts = Mg::Convert.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @converts } end end |
#new ⇒ Object
GET /converts/new GET /converts/new.xml
57 58 59 60 61 62 63 64 |
# File 'lib/mountain-goat/controllers/mg/converts_controller.rb', line 57 def new @convert = Mg::Convert.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @convert } end end |
#show ⇒ Object
GET /converts/1 GET /converts/1.xml
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/mountain-goat/controllers/mg/converts_controller.rb', line 17 def show @convert = Mg::Convert.find(params[:id]) @results_per_day = [] created_at = @convert.created_at running_date = Time.utc( created_at.year, created_at.month, created_at.day ) while running_date < Time.zone.now @results_per_day.push({ :date => running_date.to_i * 1000, :val => @convert.rallies.find( :all, :conditions => { :created_at => running_date..(running_date + 60 * 60 * 24) } ).count }) running_date += 60 * 60 * 24 end @results_by_cmt = {} @results_by_cmt_titles = {} @convert..each do |cmt| @results_by_cmt[cmt.id] = [] @results_by_cmt_titles[cmt.id] = {} i = 0 cmt..all(:select => "data, count(*) as count", :group => "data").each do || next if .data.nil? if cmt. == 'cs_meta' @results_by_cmt[cmt.id].push( { :name => i, :val => .count } ) @results_by_cmt_titles[cmt.id].merge!({ i => .data }) else @results_by_cmt[cmt.id].push( { :name => .data, :val => .count } ) end i += 1 end end respond_to do |format| format.html # show.html.erb format.xml { render :xml => @convert } end end |
#update ⇒ Object
PUT /converts/1 PUT /converts/1.xml
86 87 88 89 90 91 92 93 94 95 |
# File 'lib/mountain-goat/controllers/mg/converts_controller.rb', line 86 def update @convert = Mg::Convert.find(params[:id]) if @convert.update_attributes(params[:convert]) flash[:notice] = 'Convert was successfully updated.' redirect_to mg_convert_url :id => @convert.id else render :action => "edit" end end |