I am showing the names of rails objects on a homepage using an ajax remote true link. The homepage will show the names properly but they are followed by an array of the objects. FYI, the code in my partial view has a helper method to add text to the recipe name.
This is a sample program for my school. Any ideas on what I can do to now show the array of objects? Thanks!
`[#<Recipe id: 46, name: "recipe 1", status: true, user_id: 9, created_at: "2016-11-01 16:34:27"]`
var html = "<%= j render('recipes/recipespartial') %> "
$("#recipename").append("<%= j render('recipes/recipespartial') %> ")
<%= current_user.recipes.each do |recipe| %>
<li><%= link_to recipe.name, recipe_path(recipe)%><%=status_changed_to_cooked_helper(recipe)%></li>
<% end %>
<%= link_to "Show Recipes", recipes_path, :remote => true %>
Your partial should be
<% current_user.recipes.each do |recipe| %> #.... <% end %>
Note that there is no
current_user.recipes. In erb, any expression inside
<% %> is evaluated and
<%= %> is evaluated and interpolated into html. That is the reason you were seeing the array too.