I have "rails generated scaffold Post" and im trying to convert the posts.each index to form_for so I can use "remote: true" the AJAX.
Problem: My code doesn't show my records. It just displays the table thread headings.
class PostsController < ApplicationController
before_action :set_post, only: [:show, :edit, :update, :destroy]
# GET /posts
# GET /posts.json
def index
@posts = Post.all
@post = Post.new
end
# GET /posts/1
# GET /posts/1.json
def show
end
# GET /posts/new
def new
@post = Post.new
end
# GET /posts/1/edit
def edit
end
^^^ So i have only made these change to the controller and the following code is failing to display the post records
<tbody>
<% @posts.each do |mend| %>
<% form_for(mend) do |f| %>
<tr>
<td><%= f.text_field :title %></td>
<td><%= f.text_field :content %></td>
<td><%= f.text_field :verify %></td>
<td><%= f.text_field :date %></td>
<td><%= f.text_field :rate %></td>
<td><%= link_to 'Show', post_path(f) %></td>
<td><%= link_to 'Edit', edit_post_path(f) %></td>
<td><%= link_to 'Destroy', @post, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
<% end %>