Module: ActiveRecordSurveyApi::Concerns::Controllers::Nodes
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/active_record_survey_api/concerns/controllers/nodes.rb
Instance Method Summary collapse
- #all_nodes ⇒ Object
- #find_survey ⇒ Object
- #json_params ⇒ Object
- #new_node(params) ⇒ Object
- #node_by_id(id) ⇒ Object
- #node_params ⇒ Object
Instance Method Details
#all_nodes ⇒ Object
7 8 9 |
# File 'lib/active_record_survey_api/concerns/controllers/nodes.rb', line 7 def all_nodes @survey.nodes end |
#find_survey ⇒ Object
31 32 33 |
# File 'lib/active_record_survey_api/concerns/controllers/nodes.rb', line 31 def find_survey self.instance_variable_set "@survey", ActiveRecordSurvey::Survey.find(params[:survey_id]) end |
#json_params ⇒ Object
19 20 21 |
# File 'lib/active_record_survey_api/concerns/controllers/nodes.rb', line 19 def json_params ActionController::Parameters.new(JSON.parse(request.body.read)) end |
#new_node(params) ⇒ Object
15 16 17 |
# File 'lib/active_record_survey_api/concerns/controllers/nodes.rb', line 15 def new_node(params) ActiveRecordSurvey::Node.new(node_params) end |
#node_by_id(id) ⇒ Object
11 12 13 |
# File 'lib/active_record_survey_api/concerns/controllers/nodes.rb', line 11 def node_by_id(id) ActiveRecordSurvey::Node.find(id) end |
#node_params ⇒ Object
23 24 25 |
# File 'lib/active_record_survey_api/concerns/controllers/nodes.rb', line 23 def node_params json_params.require(:node).permit(:text, nodes: []) end |