parent
48650a2a91
commit
c50c77a7ca
@ -1,2 +1,46 @@
|
||||
class MemosController < ApplicationController
|
||||
|
||||
def new
|
||||
@memo = Memo.new
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.json { render json: @memo }
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@memo = Memo.find(params[:id])
|
||||
@replies = @memo.replies
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.json { render json: @memo }
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@memo = Memo.new(params[:memo])
|
||||
@memo.author_id = User.current.id
|
||||
|
||||
respond_to do |format|
|
||||
if @memo.save
|
||||
format.html { redirect_to @memo, notice: 'Memo was successfully created.' }
|
||||
format.json { render json: @memo, status: :created, location: @memo }
|
||||
else
|
||||
format.html { render action: "new" }
|
||||
format.json { render json: @memo.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@memo = Memo.find(params[:id])
|
||||
@memo.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to memos_url }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,6 +1,27 @@
|
||||
<p id="notice"><%= notice %></p>
|
||||
<p><%= %></p>
|
||||
<p><%= %></p>
|
||||
<p id="notice">
|
||||
<%= notice %>
|
||||
</p>
|
||||
<p>
|
||||
<%= %>
|
||||
</p>
|
||||
<p>
|
||||
<%= %>
|
||||
</p>
|
||||
|
||||
<%= link_to 'Edit', edit_forum_path(@forum) %> |
|
||||
<%= link_to 'Back', forums_path %>
|
||||
<%= link_to 'new_topic', new_forum_memo_path(@forum) %>
|
||||
<table>
|
||||
<tr>
|
||||
<th>subject</th>
|
||||
<th>content</th>
|
||||
<th>author</th>
|
||||
</tr>
|
||||
<% @memos.each do |memo| %>
|
||||
<tr>
|
||||
<td><%= link_to memo.subject, forum_memo_path(memo) %></td>
|
||||
<td><%= memo.content %></td>
|
||||
<td><%= memo.author %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
|
@ -0,0 +1,36 @@
|
||||
<p id="notice">
|
||||
<%= notice %>
|
||||
</p>
|
||||
<p>
|
||||
<%= %>
|
||||
</p>
|
||||
<p>
|
||||
<%= %>
|
||||
</p>
|
||||
<table>
|
||||
<tr>
|
||||
<th>subject</th>
|
||||
<th>content</th>
|
||||
<th>author</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%= link_to @memo.subject, forum_memo_path(@memo) %></td>
|
||||
<td><%= @memo.content %></td>
|
||||
<td><%= @memo.author %></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>subject</th>
|
||||
<th>content</th>
|
||||
<th>author</th>
|
||||
</tr>
|
||||
<% @replies.each do |reply| %>
|
||||
<tr>
|
||||
<td><%= link_to reply.subject, forum_memo_path(reply) %></td>
|
||||
<td><%= reply.content %></td>
|
||||
<td><%= reply.author %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
Loading…
Reference in new issue