Commit 1d4ab5abc754d9245b234d47046dcd0e24e5bc9e
1 parent
0d8d17f8
Exists in
master
and in
1 other branch
Removed set_autoactivate_ideas_from_abroad
Showing
3 changed files
with
7 additions
and
32 deletions
Show diff stats
app/controllers/questions_controller.rb
| ... | ... | @@ -94,29 +94,6 @@ class QuestionsController < InheritedResources::Base |
| 94 | 94 | end |
| 95 | 95 | end |
| 96 | 96 | |
| 97 | - | |
| 98 | - | |
| 99 | - def set_autoactivate_ideas_from_abroad | |
| 100 | - #expire_page :action => :index | |
| 101 | - logger.info("INSIDE autoactivate ideas") | |
| 102 | - | |
| 103 | - | |
| 104 | - @question = current_user.questions.find(params[:id]) | |
| 105 | - @question.it_should_autoactivate_ideas = params[:question][:it_should_autoactivate_ideas] | |
| 106 | - | |
| 107 | - respond_to do |format| | |
| 108 | - if @question.save | |
| 109 | - logger.info "successfully set this question to autoactive ideas #{@question.inspect}" | |
| 110 | - format.xml { render :xml => true } | |
| 111 | - format.json { render :json => true} | |
| 112 | - else | |
| 113 | - logger.info "Some error in saving question, #{@question.inspect}" | |
| 114 | - format.xml { render(:xml => false) and return} | |
| 115 | - format.json { render :json => false } | |
| 116 | - end | |
| 117 | - end | |
| 118 | - | |
| 119 | - end | |
| 120 | 97 | def export |
| 121 | 98 | type = params[:type] |
| 122 | 99 | response_type = params[:response_type] |
| ... | ... | @@ -314,6 +291,13 @@ class QuestionsController < InheritedResources::Base |
| 314 | 291 | end |
| 315 | 292 | end |
| 316 | 293 | |
| 294 | + def update | |
| 295 | + # prevent AttributeNotFound error and only update actual Question columns, since we add extra information in 'show' method | |
| 296 | + question_attributes = Question.new.attribute_names | |
| 297 | + params[:question] = params[:question].delete_if {|key, value| !question_attributes.include?(key)} | |
| 298 | + update! | |
| 299 | + end | |
| 300 | + | |
| 317 | 301 | protected |
| 318 | 302 | end |
| 319 | 303 | ... | ... |
config/routes.rb
| ... | ... | @@ -5,7 +5,6 @@ ActionController::Routing::Routes.draw do |map| |
| 5 | 5 | map.resources :questions, :member => { :object_info_totals_by_date => :get, |
| 6 | 6 | :object_info_by_visitor_id => :get, |
| 7 | 7 | :export => :post, |
| 8 | - :set_autoactivate_ideas_from_abroad => :put, | |
| 9 | 8 | :activate => :put, |
| 10 | 9 | :suspend => :put}, |
| 11 | 10 | :collection => {:all_num_votes_by_visitor_id => :get, | ... | ... |
spec/controllers/questions_controller_spec.rb
| ... | ... | @@ -33,12 +33,4 @@ describe QuestionsController do |
| 33 | 33 | @response.body.should have_tag("visitor_ideas") |
| 34 | 34 | |
| 35 | 35 | end |
| 36 | - | |
| 37 | - it "can be set to autoactivate questions" do | |
| 38 | - put :set_autoactivate_ideas_from_abroad, :id => @question.id, :format => "xml", :question => {:it_should_autoactivate_ideas => true} | |
| 39 | - assigns[:question].should == @question | |
| 40 | - assigns[:question].it_should_autoactivate_ideas.should be_true | |
| 41 | - @response.body.should == "true" | |
| 42 | - end | |
| 43 | - | |
| 44 | 36 | end | ... | ... |