From a03d6811d53eab61d9e30f8c66802ae77e5a9049 Mon Sep 17 00:00:00 2001 From: Dhruv Kapadia Date: Thu, 4 Feb 2010 16:40:52 -0500 Subject: [PATCH] Exposed interface for users to set ideas to auto-activate --- app/controllers/questions_controller.rb | 26 ++++++++++++++++++++++++-- config/routes.rb | 2 +- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/app/controllers/questions_controller.rb b/app/controllers/questions_controller.rb index e94e637..6f59432 100644 --- a/app/controllers/questions_controller.rb +++ b/app/controllers/questions_controller.rb @@ -40,12 +40,34 @@ class QuestionsController < InheritedResources::Base end end end -end + def set_autoactivate_ideas_from_abroad + authenticate + expire_page :action => :index + logger.info("INSIDE autoactivate ideas") + + + @question = current_user.questions.find(params[:id]) + @question.it_should_autoactivate_ideas = params[:question][:it_should_autoactivate_ideas] + + respond_to do |format| + if @question.save + logger.info "successfully set this question to autoactive ideas #{@question.inspect}" + format.xml { render :xml => true } + format.json { render :json => true} + else + logger.info "Some error in saving question, #{@question.inspect}" + format.xml { render(:xml => false) and return} + format.json { render :json => false } + end + end + + end +end class String unless defined? "".lines alias lines to_a #Ruby version compatibility end -end \ No newline at end of file +end diff --git a/config/routes.rb b/config/routes.rb index 158e383..6deec97 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,6 +1,6 @@ ActionController::Routing::Routes.draw do |map| map.resources :clicks - map.resources :questions, :member => { :activate => :put, :suspend => :put} do |question| + map.resources :questions, :member => { :set_autoactivate_ideas_from_abroad => :put, :activate => :put, :suspend => :put} do |question| question.resources :items question.resources :prompts, :member => {:vote_left => :post, :vote_right => :post, :skip => :post, :vote => :post}, :collection => {:single => :get, :index => :get} -- libgit2 0.21.2