Commit a03d6811d53eab61d9e30f8c66802ae77e5a9049

Authored by Dhruv Kapadia
1 parent 545402a0

Exposed interface for users to set ideas to auto-activate

app/controllers/questions_controller.rb
@@ -40,12 +40,34 @@ class QuestionsController < InheritedResources::Base @@ -40,12 +40,34 @@ class QuestionsController < InheritedResources::Base
40 end 40 end
41 end 41 end
42 end 42 end
43 -end  
44 43
  44 + def set_autoactivate_ideas_from_abroad
  45 + authenticate
  46 + expire_page :action => :index
  47 + logger.info("INSIDE autoactivate ideas")
  48 +
  49 +
  50 + @question = current_user.questions.find(params[:id])
  51 + @question.it_should_autoactivate_ideas = params[:question][:it_should_autoactivate_ideas]
  52 +
  53 + respond_to do |format|
  54 + if @question.save
  55 + logger.info "successfully set this question to autoactive ideas #{@question.inspect}"
  56 + format.xml { render :xml => true }
  57 + format.json { render :json => true}
  58 + else
  59 + logger.info "Some error in saving question, #{@question.inspect}"
  60 + format.xml { render(:xml => false) and return}
  61 + format.json { render :json => false }
  62 + end
  63 + end
  64 +
  65 + end
  66 +end
45 67
46 class String 68 class String
47 unless defined? "".lines 69 unless defined? "".lines
48 alias lines to_a 70 alias lines to_a
49 #Ruby version compatibility 71 #Ruby version compatibility
50 end 72 end
51 -end  
52 \ No newline at end of file 73 \ No newline at end of file
  74 +end
config/routes.rb
1 ActionController::Routing::Routes.draw do |map| 1 ActionController::Routing::Routes.draw do |map|
2 map.resources :clicks 2 map.resources :clicks
3 - map.resources :questions, :member => { :activate => :put, :suspend => :put} do |question| 3 + map.resources :questions, :member => { :set_autoactivate_ideas_from_abroad => :put, :activate => :put, :suspend => :put} do |question|
4 question.resources :items 4 question.resources :items
5 question.resources :prompts, :member => {:vote_left => :post, :vote_right => :post, :skip => :post, :vote => :post}, 5 question.resources :prompts, :member => {:vote_left => :post, :vote_right => :post, :skip => :post, :vote => :post},
6 :collection => {:single => :get, :index => :get} 6 :collection => {:single => :get, :index => :get}