0

I'm getting undefined method error:

undefined method `challenges_path'

I thought I had my form correct, _form.haml

= simple_form_for [@skit, @challenge], html: { class: "form-horizontal" } do |f|

The link to the form above:

= link_to 'Submit', new_skit_challenge_path(params[:skit_id]), class: "btn btn-default" 

This is my routes

resources :skits do
  resources :challenges
end

This is my challenge_controller.rb

def new
  @challenge = Challenge.new
end

What am I doing wrong? What else information do you need that can help debug this issue?

hellomello
  • 8,219
  • 39
  • 151
  • 297

2 Answers2

0

Perhaps you could try doing this:

resources :skits, shallow: true do
  resources :challenges
end
Ho Man
  • 2,308
  • 11
  • 16
0

undefined method `challenges_path'

The problem is @skit is nil because you haven't initialized @skit in the new action.

def new
  @challenge = Challenge.new
  @skit = Skit.find(params[:skit_id]) #you need this line
end
Pavan
  • 33,316
  • 7
  • 50
  • 76