Class: Sechat::QuestionsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Sechat::QuestionsController
- Defined in:
- lib/sechat/controllers/questions_controller.rb
Instance Method Summary collapse
- #build_question(params = nil) ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #resource_class ⇒ Object
- #show ⇒ Object
- #unanswered ⇒ Object
- #update ⇒ Object
Instance Method Details
#build_question(params = nil) ⇒ Object
52 53 54 |
# File 'lib/sechat/controllers/questions_controller.rb', line 52 def build_question(params = nil) resource_class.new(params) end |
#create ⇒ Object
30 31 32 33 34 |
# File 'lib/sechat/controllers/questions_controller.rb', line 30 def create @question = build_question(params[:question]) @question.save respond_with(@question, :location => { :action => 'show', :id => @question.to_param }) end |
#destroy ⇒ Object
42 43 44 45 46 |
# File 'lib/sechat/controllers/questions_controller.rb', line 42 def destroy @question = resource_class.find(params[:id]) @question.destroy respond_with(@question, :location => { :action => 'index' }) end |
#edit ⇒ Object
26 27 28 |
# File 'lib/sechat/controllers/questions_controller.rb', line 26 def edit @question = resource_class.find(params[:id]) end |
#index ⇒ Object
3 4 5 6 |
# File 'lib/sechat/controllers/questions_controller.rb', line 3 def index @questions = resource_class.latest respond_with(@questions) end |
#new ⇒ Object
21 22 23 24 |
# File 'lib/sechat/controllers/questions_controller.rb', line 21 def new @question = build_question respond_with(@question) end |
#resource_class ⇒ Object
48 49 50 |
# File 'lib/sechat/controllers/questions_controller.rb', line 48 def resource_class Question end |
#show ⇒ Object
16 17 18 19 |
# File 'lib/sechat/controllers/questions_controller.rb', line 16 def show @question = resource_class.find(params[:id]) respond_with(@question) end |
#unanswered ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/sechat/controllers/questions_controller.rb', line 8 def unanswered @questions = resource_class.unanswered.latest respond_with(@questions) do |format| format.html { render 'index' } end end |
#update ⇒ Object
36 37 38 39 40 |
# File 'lib/sechat/controllers/questions_controller.rb', line 36 def update @question = resource_class.find(params[:id]) @question.update_attributes(params[:question]) respond_with(@question, :location => { :action => 'show', :id => @question.to_param }) end |