index.html.erb 1.73 KB
<h3 class="title">
    文章管理
    <small>
        <%= link_to '去首页', root_path %>
        /
        <%= link_to '注销', sign_out_path %>
        /
        <%= link_to '发布文章', new_post_path(schan: params[:schan], scate: params[:scate], screa: params[:screa], page: params[:page]) %>
    </small>
</h3>
<table class="list">
  <tr>
    <th width="3%">
        ID
    </th>
    <th width="25%">
        <!-- <input> -->
        标题
    </th>
    <th width="16%">
        <%= link_to "类别#{params[:scate] == 'desc' ? '△' : '▽'}", posts_path(scate: params[:scate] == 'desc' ? 'asc' : 'desc') %>
    </th>
    <th width="16%">
        <%= link_to "频道#{params[:schan] == 'desc' ? '△' : '▽'}", posts_path(schan: params[:schan] == 'desc' ? 'asc' : 'desc') %>
    </th>
    <th width="10%">
        <%= link_to "日期#{params[:screa] == 'desc' ? '▽' : '△'}", posts_path(screa: params[:screa] == 'desc' ? 'asc' : 'desc') %>
    </th>
    <th width="10%">别名</th>
    <th width="20%">操作</th>
  </tr>

<% @posts.each do |post| %>
  <tr>
    <td><%= post.id %></td>
    <td><%= post.title %></td>
    <td><%= Post::CATE[post.chan][:cate][post.cate] %></td>
    <td><%= Post::CATE[post.chan][:name] %></td>
    <td><%= post.created_at.to_date %></td>
    <td><%= post.flag %></td>
    <td>
        <%= link_to '详细', post_path(post, schan: params[:schan], scate: params[:scate], screa: params[:screa], page: params[:page]) %>
        /
        <%= link_to '编辑', edit_post_path(post, schan: params[:schan], scate: params[:scate], screa: params[:screa], page: params[:page]) %>
        /
        <%= link_to '删除', post, method: :delete, data: { confirm: '确定删除?' } %>
  </tr>
<% end %>
</table>
<%= paginate @posts %>