diff --git a/app/controllers/memos_controller.rb b/app/controllers/memos_controller.rb index 101ae69e2..4453d5f5e 100644 --- a/app/controllers/memos_controller.rb +++ b/app/controllers/memos_controller.rb @@ -22,8 +22,8 @@ class MemosController < ApplicationController def create @memo = Memo.new(params[:memo]) + @memo.forum_id = params[:forum_id] @memo.author_id = User.current.id - @back_memo_id = @memo.id if @memo.parent_id @back_memo_id ||= @memo.parent_id @@ -33,14 +33,11 @@ class MemosController < ApplicationController respond_to do |format| if @memo.save + @back_memo_id = @memo.id @parent_memo.last_reply_id = @memo.id if @parent_memo - if @parent_memo.save - format.html { redirect_to forum_memo_path(@memo.forum_id, @back_memo_id), notice: 'Memo was successfully created.' } - format.json { render json: @memo, status: :created, location: @memo } - else - format.html { redirect_to forum_memo_path(@memo.forum_id, @back_memo_id) } - format.json { render json: @memo.errors, status: :unprocessable_entity } - end + @parent_memo.save if @parent_memo + format.html { redirect_to forum_memo_path(@memo.forum_id, @back_memo_id), 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 } diff --git a/app/views/memos/_topic_form.html.erb b/app/views/memos/_topic_form.html.erb new file mode 100644 index 000000000..2cc5fbcf1 --- /dev/null +++ b/app/views/memos/_topic_form.html.erb @@ -0,0 +1,18 @@ +<%= labelled_form_for(@memo, :url => forum_memos_path) do |f| %> + <% if @memo.errors.any? %> +
<%= f.text_field :subject, :required => true %>
+<%= f.text_field :content, :required => true, :size => 80 %>
+ <%= f.submit %> +