Ruby on Rails. Error with relation in models
<p>I have two models in ruby. The school and the course.</p>

<p>The <code>course</code> model have:</p>

<pre><code>belongs_to :school
</code></pre>

<p>The <code>school</code> model have:</p>

<pre><code>has_many :courses
</code></pre>

<p>The routes are:</p>

<pre><code>Rails.application.routes.draw do
resources :projects
resources :schools
resources :documents
resources :courses
resources :subjects
resources :people
resources :persontypes
end
</code></pre>

<p>the method create for courses is :</p>

<pre><code>def create
 @course = Course.new(course_params)

 if @course.save
    redirect_to courses_path
 else
  render 'new'
 end
end
</code></pre>

<p>My schema is:</p>

<pre><code>create_table "courses", force: :cascade do |t|
  t.text     "description"
  t.datetime "created_at",  null: false
  t.datetime "updated_at",  null: false
  t.text     "name"
  t.integer  "code"
  t.text     "initials"
  t.integer  "school_id"
 end


create_table "schools", force: :cascade do |t|
t.text     "description"
t.datetime "created_at",  null: false
t.datetime "updated_at",  null: false
t.text     "name"
t.integer  "code"
t.text     "initials"
end
</code></pre>

<p>I create a school. But when I try to create a course it gives me a error: It´s say that I need a school.</p>

<p>I already have both models related but how can I put in the create view of the courses a list to choose to which school belongs that course?</p>

<p>EDITED:</p>

<p>My controler for delete method is </p>

<pre><code>def destroy
    @course = Course.find(params[:id])
    @course.destroy

    redirect_to courses_path
end
</code></pre>

<p>When I delete a course, instead of the course being deleted, I'm redirected to the view edit.</p>

<p>This is the code for the delete link:</p>

<pre><code>&lt;td&gt;&lt;%= link_to 'Remover', course_path(course), 
method: :delete, 
data: { confirm: 'Tem a certeza que deseja eliminar este Curso?' } %&gt;&lt;/td&gt;
</code></pre>

<p>Is a route problem?</p>