Arash Hadipanah
Arash Hadipanah

Reputation: 145

Rails create custom view and route similar to new.html.erb

I'm looking to create a custom nested view that behaves similar to new.html.erb but not exactly sure how to do so with Rails 6.

In my routes I've defined the following -

resources :courses do
  resources :courselocations, shallow: true do
    member do
      match :new_modal, via: :all
    end
  end
end

My controller is defined as follows -

  def new_modal
    @courselocation = Courselocation.new
  end

The issue I'm facing is that whenever I click the link new_modal_admin_course_courselocations_path(@course) w/ for the custom route, I get the following error which seems to show that rails is not treating this as an action similar to new

ActiveRecord::RecordNotFound (Couldn't find Courselocation without an ID):

Any help would be appreciated.

Upvotes: 0

Views: 96

Answers (0)

Related Questions