jeudi 2 janvier 2020

not able to render form from different model in rails

i am new to rails was building new rails app. i have post model and a post_status model that contains Boolean status attribute.the database connection between post and post_status model is belongs_to and has_many. i want to render all posts from post model along with accept reject radio submit button that sets Boolean of post_status model. i tried but i am getting error please help.

routes.rb

  resources :posts do
    resources : post_status
  end
get '/admin' => 'admin#index'

admin index.html.erb

  <table>
    <thead>
      <tr>
        <th>title</th>
        <th>User Email </th>
        <th>Uploaded Date</th>
        <th>Status</th>
        <th colspan="2"></th>
      </tr>
    </thead>

    <tbody>
      <% @posts.each do |post| %>
        <tr>
            <td><%= post.title %></td>
            <td><%= post.user.email %></td>
            <td><%= post.created_at.strftime('%d-%m-%Y') %></td>

            <% if post.post_status.empty? %>
              <td><%= " Pending" %></td>
            <% else %>
              <% post.post_status.each do |post_status| %>
                <% if post_status.false == false %>
                  <td><%= ' Rejected' %></td>
                <% else  %>
                  <td ><%= " Approved" %></td>
                <% end %>
              <% end %>
            <% end %>
            <td><%= "HERE I WANT TO RENDER THE FORM WITH ACCEPT REJECT AND SUBMIT BUTTON FOR EACH POST TO ADMIN DASHBOARD" %></td>
        </tr>
      <% end %>
    </tbody>
  </table>

Aucun commentaire:

Enregistrer un commentaire