I have Q+A model inside an events model and having issue with understanding how the nested routes work. I'm getting a No route matches {:action=>"create", :controller=>"event_questions" and
missing required keys: [:event_id]`
My question form sits inside my show.hrml.erb for my event model right now. Some of the relationship stuff is from neo4j gem so it isn't standard but the issue shouldn't be related to that. From what I know, I am posting to /events/events_id/event_questions
events_controller.rb
def show
@event = Event.find(params[:id])
@event_question = EventQuestion.new
end
event.rb
has_many :out, :event_questions, type: 'questions_of'
event_question.rb
has_one :in, :events, origin: :event_questions
events/show.html.erb
<%= form_for [:event, @event_question] do |f| %>
#form stuff
<% end %>
event_questions_controller.rb
def create
@event_question = EventQuestion.new(event_question_params)
if @event_question.save
@event = Event.find(params[:event_id])
@event_question.update(admin: current_user.facebook_id)
@event_question.events << @event
redirect_to @event
else
redirect_to :back
end
end
routes.rb
resources :events do
resources :event_questions, only: [:create, :destroy]
end