0

イベントのインデックス ページからショー ページにアクセスしようとしているだけですが、このモンゴイド エラーが発生し続けます。

Mongoid::Errors::DocumentNotFound at /events/%23%3CMongoid::Criteria:0x007f8ac1da9578%3E

Summary: When calling Event.find with an id or array of ids, each parameter must match a document in the database or this error will be raised. The search was for the id(s): # ... (1 total) and the following ids were not found: #. Resolution: Search for an id that is in the database or set the Mongoid.raise_not_found_error configuration option to false, which will cause a nil to be returned instead of raising this error when searching for a single id, or only the matched documents when searching for multiples.

コントローラ

  def index
    @event = Event.all
  end

  def show
    @event = Event.find(params[:id])
  end

ルート

  resources :events do
    resources :leads, only: [:new, :create]
    resources :registrations, only: [:new, :create]
  end

インデックス ビュー

<ul>
  <% @event.each do |e|  %>
  <li><%= link_to e.title, event_path(@event) %></li>
  <% end %>
</ul>
4

1 に答える 1