Add timestamps to Topic. Add fields on topic list.

This commit is contained in:
taitus
2017-08-07 13:42:12 +02:00
parent 579a174704
commit c6e48946bd
5 changed files with 12 additions and 3 deletions

View File

@@ -1,4 +1,5 @@
class TopicsController < ApplicationController
# include CommentableActions
before_action :set_community

View File

@@ -6,6 +6,10 @@
<% topics.each do |topic| %>
<div id="<%= dom_id(topic) %>">
<%= link_to topic.title, community_topic_path(@community, topic) %>
<br>
<%= topic.author.name %>
<br>
<%= I18n.l topic.created_at %>
<% if topic.author == current_user %>
<%= link_to t("topic.edit"), edit_community_topic_path(@community.id, topic), class: 'button expanded' %>
<% end %>

View File

@@ -1,5 +1,6 @@
<div class="topic-new row">
<div class="small-12 medium-9 column">
<%= render "shared/back_link" %>
<h1><%= t("topic.create") %></h1>
<%= render '/topics/form' %>

View File

@@ -4,6 +4,7 @@ class CreateTopics < ActiveRecord::Migration
t.string :title, null: false
t.integer :author_id
t.references :community, index: true
t.timestamps null: false
end
end
end

View File

@@ -891,9 +891,11 @@ ActiveRecord::Schema.define(version: 20170807082243) do
add_index "tags", ["spending_proposals_count"], name: "index_tags_on_spending_proposals_count", using: :btree
create_table "topics", force: :cascade do |t|
t.string "title", null: false
t.integer "author_id"
t.integer "community_id"
t.string "title", null: false
t.integer "author_id"
t.integer "community_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "topics", ["community_id"], name: "index_topics_on_community_id", using: :btree