user2513971
user2513971

Reputation:

Ruby render error

I work with faye railscast and have error in view:

<%= render @messages %>

and error:

'nil' is not an ActiveModel-compatible object. It must implement :to_partial_path.

What does this means? <%= @messages %> works, but with render doesnt.

Upvotes: 1

Views: 3575

Answers (2)

Taimoor Changaiz
Taimoor Changaiz

Reputation: 10684

You are looking for collection rendering, But for that @messages should by array of objects of Message Model.

You can check this

<% unless @messages.blank? %>
 <%= render @messages %>
<%end%>

Upvotes: 0

Pierre-Louis Gottfrois
Pierre-Louis Gottfrois

Reputation: 17631

The error message is telling you that @messages is nil. When calling

<%= render @messages %>

render is expecting an ActiveModel-compatible object.

You need to check how @messages is created in your controller.

Upvotes: 2

Related Questions