Commit 6aa016fdfa45ff560d5debfbf0bf0a26a1472ea8

Authored by Dhruv Kapadia
1 parent cf488e8d

Changes to support exporting data

app/controllers/questions_controller.rb
... ... @@ -4,7 +4,6 @@ class QuestionsController < InheritedResources::Base
4 4 respond_to :xml, :json
5 5 respond_to :csv, :only => :export #leave the option for xml export here
6 6 belongs_to :site, :optional => true
7   - #has_scope :voted_on_by
8 7  
9 8 def show
10 9 @question = Question.find(params[:id])
... ... @@ -69,7 +68,8 @@ class QuestionsController < InheritedResources::Base
69 68  
70 69 end
71 70 def export
72   -
  71 + authenticate
  72 +
73 73 type = params[:type]
74 74  
75 75 if type == 'votes'
... ...
app/models/question.rb
... ... @@ -8,6 +8,7 @@ class Question < ActiveRecord::Base
8 8 has_many :choices, :order => 'score DESC'
9 9 has_many :prompts do
10 10 def pick(algorithm = nil)
  11 + logger.info( "inside Question#prompts#pick - never called?")
11 12 if algorithm
12 13 algorithm.pick_from(self) #todo
13 14 else
... ...
config/routes.rb
1 1 ActionController::Routing::Routes.draw do |map|
2 2 map.resources :clicks
3   - map.resources :questions, :member => { :export => :get, :set_autoactivate_ideas_from_abroad => :put, :activate => :put, :suspend => :put} do |question|
  3 + map.resources :questions, :member => { :export => :post, :set_autoactivate_ideas_from_abroad => :put, :activate => :put, :suspend => :put} do |question|
4 4 question.resources :items
5 5 question.resources :prompts, :member => {:vote_left => :post, :vote_right => :post, :skip => :post, :vote => :post},
6 6 :collection => {:single => :get, :index => :get}
... ...