adds consistency to answer's namespace
This commit is contained in:
@@ -1,14 +1,14 @@
|
|||||||
class Admin::Poll::AnswersController < Admin::Poll::BaseController
|
class Admin::Poll::Questions::AnswersController < Admin::Poll::BaseController
|
||||||
before_action :load_question
|
before_action :load_question
|
||||||
|
|
||||||
load_and_authorize_resource :question, class: "::Poll::Question"
|
load_and_authorize_resource :question, class: "::Poll::Question"
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@answer = Poll::QuestionAnswer.new
|
@answer = ::Poll::Question::Answer.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@answer = Poll::QuestionAnswer.new(answer_params)
|
@answer = ::Poll::Question::Answer.new(answer_params)
|
||||||
|
|
||||||
if @answer.save
|
if @answer.save
|
||||||
redirect_to admin_question_path(@question),
|
redirect_to admin_question_path(@question),
|
||||||
@@ -15,7 +15,7 @@ class Poll::Question < ActiveRecord::Base
|
|||||||
|
|
||||||
has_many :comments, as: :commentable
|
has_many :comments, as: :commentable
|
||||||
has_many :answers
|
has_many :answers
|
||||||
has_many :question_answers, class_name: 'Poll::QuestionAnswer', foreign_key: 'poll_question_id'
|
has_many :question_answers, class_name: 'Poll::Question::Answer', foreign_key: 'poll_question_id'
|
||||||
has_many :partial_results
|
has_many :partial_results
|
||||||
belongs_to :proposal
|
belongs_to :proposal
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class Poll::QuestionAnswer < ActiveRecord::Base
|
class Poll::Question::Answer < ActiveRecord::Base
|
||||||
belongs_to :question, class_name: 'Poll::Question', foreign_key: 'poll_question_id'
|
belongs_to :question, class_name: 'Poll::Question', foreign_key: 'poll_question_id'
|
||||||
|
|
||||||
validates :title, presence: true
|
validates :title, presence: true
|
||||||
@@ -301,7 +301,7 @@ Rails.application.routes.draw do
|
|||||||
end
|
end
|
||||||
|
|
||||||
resources :questions do
|
resources :questions do
|
||||||
resources :answers, only: [:new, :create]
|
resources :answers, only: [:new, :create], controller: 'questions/answers'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user