Commit a03d6811d53eab61d9e30f8c66802ae77e5a9049
1 parent
545402a0
Exists in
master
and in
1 other branch
Exposed interface for users to set ideas to auto-activate
Showing
2 changed files
with
25 additions
and
3 deletions
Show diff stats
app/controllers/questions_controller.rb
... | ... | @@ -40,12 +40,34 @@ class QuestionsController < InheritedResources::Base |
40 | 40 | end |
41 | 41 | end |
42 | 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 | 68 | class String |
47 | 69 | unless defined? "".lines |
48 | 70 | alias lines to_a |
49 | 71 | #Ruby version compatibility |
50 | 72 | end |
51 | -end | |
52 | 73 | \ No newline at end of file |
74 | +end | ... | ... |
config/routes.rb
1 | 1 | ActionController::Routing::Routes.draw do |map| |
2 | 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 | 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} | ... | ... |