dan
dan

Reputation: 1080

Rails - creating object using nested restful routes

@shift_requirement belongs_to @reckoner - and in my routes

resources :reckoners do
  resources :shift_requirements
end

In /reckoners/show.html.erb I have

<%= link_to 'Add a shift', [:new, @reckoner, @shift_requirement] %>

... but I'm getting a new @reckoner rather than the new @shift_requirement that I want - where am I going wrong?

Upvotes: 0

Views: 36

Answers (1)

Marek Lipka
Marek Lipka

Reputation: 51161

You should have:

<%= link_to 'Add a shift', [:new, @reckoner, :shift_requirement] %>

Upvotes: 1

Related Questions