From 3e752b94eccd081881f6f9c4640f4ee1b31922e3 Mon Sep 17 00:00:00 2001 From: Rueshyna Date: Wed, 5 Dec 2012 15:09:58 +0800 Subject: [PATCH] fixed new co-author relation bug.... --- app/controllers/desktop/co_author_relations_controller.rb | 5 +++-- app/views/desktop/co_author_relations/_show_form.html.erb | 2 ++ app/views/desktop/co_author_relations/index.html.erb | 4 +--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/controllers/desktop/co_author_relations_controller.rb b/app/controllers/desktop/co_author_relations_controller.rb index 787ad36c..cb01915e 100644 --- a/app/controllers/desktop/co_author_relations_controller.rb +++ b/app/controllers/desktop/co_author_relations_controller.rb @@ -14,10 +14,11 @@ class Desktop::CoAuthorRelationsController < ApplicationController def create @new_relation = CoAuthorRelation.new(params[:co_author_relation]) + @co_author_relations = CoAuthorRelation.all if @new_relation.save - newv = render_to_string :partial=>"show_form", :object=>@new_relation - render json: {success:true, msg: "New Relation successfully saved!","newvalue"=>newv}.to_json + newv = render_to_string partial: "show_form", object: @co_author_relations + render json: {success: true, msg: "New Relation successfully saved!", newvalue: newv}.to_json else error_msg = @new_relation.errors.full_messages.join("
") render json: {success: false, msg: error_msg}.to_json diff --git a/app/views/desktop/co_author_relations/_show_form.html.erb b/app/views/desktop/co_author_relations/_show_form.html.erb index bdb9f72e..d3c803d3 100644 --- a/app/views/desktop/co_author_relations/_show_form.html.erb +++ b/app/views/desktop/co_author_relations/_show_form.html.erb @@ -1,4 +1,6 @@ + <% @co_author_relations.each do |co_author_relation| %> <%= co_author_relation.relation %> <%= link_to 'Destroy', desktop_co_author_relation_path(co_author_relation), confirm: 'Are you sure?', method: :delete, :class=>"bt-delete" %> + <% end %> diff --git a/app/views/desktop/co_author_relations/index.html.erb b/app/views/desktop/co_author_relations/index.html.erb index 24791349..157db942 100644 --- a/app/views/desktop/co_author_relations/index.html.erb +++ b/app/views/desktop/co_author_relations/index.html.erb @@ -12,8 +12,6 @@ - <% @co_author_relations.each do |co_author_relation| %> - <%= render :partial => 'show_form', locals: {:co_author_relation => co_author_relation} %> - <% end %> + <%= render :partial => 'show_form'%>