From 270644a959ce01b0efb76ee36100009934236851 Mon Sep 17 00:00:00 2001 From: Rueshyna Date: Wed, 5 Dec 2012 18:24:50 +0800 Subject: [PATCH] add back buton in relation page --- app/controllers/desktop/co_author_relations_controller.rb | 8 ++++---- app/views/desktop/co_author_relations/_form.html.erb | 3 +++ app/views/desktop/co_author_relations/_new.html.erb | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/controllers/desktop/co_author_relations_controller.rb b/app/controllers/desktop/co_author_relations_controller.rb index 52499498..6ee8bce1 100644 --- a/app/controllers/desktop/co_author_relations_controller.rb +++ b/app/controllers/desktop/co_author_relations_controller.rb @@ -16,18 +16,18 @@ class Desktop::CoAuthorRelationsController < ApplicationController end def new - @new_relation = CoAuthorRelation.new + @co_author_relation = CoAuthorRelation.new end def create - @new_relation = CoAuthorRelation.new(params[:co_author_relation]) + @co_author_relation = CoAuthorRelation.new(params[:co_author_relation]) @co_author_relations = CoAuthorRelation.all - if @new_relation.save + if @co_author_relation.save 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("
") + error_msg = @co_author_relation.errors.full_messages.join("
") render json: {success: false, msg: error_msg}.to_json end end diff --git a/app/views/desktop/co_author_relations/_form.html.erb b/app/views/desktop/co_author_relations/_form.html.erb index 04ebe5ed..37d49006 100644 --- a/app/views/desktop/co_author_relations/_form.html.erb +++ b/app/views/desktop/co_author_relations/_form.html.erb @@ -1,2 +1,5 @@ +<% if not @co_author_relation.new_record? %> + <%= submit_tag "Cancel", :type => "button", class: "bt-cancel ini_input hp hh2 thmadm thmtxt" %> +<% end %> <%= f.text_field :relation %> <%= f.submit "Save" %> diff --git a/app/views/desktop/co_author_relations/_new.html.erb b/app/views/desktop/co_author_relations/_new.html.erb index 6e137c88..fc0d0891 100644 --- a/app/views/desktop/co_author_relations/_new.html.erb +++ b/app/views/desktop/co_author_relations/_new.html.erb @@ -1,3 +1,3 @@ -<%= form_for(@new_relation , url: desktop_co_author_relations_path, html:{"form-type"=>"ajax_form", "callback-method"=>"coauthorRelationForm"} ) do |f| %> +<%= form_for(@co_author_relation, url: desktop_co_author_relations_path, html:{"form-type"=>"ajax_form", "callback-method"=>"coauthorRelationForm"} ) do |f| %> <%= render partial: 'desktop/co_author_relations/form' , locals: {:f => f}%> <% end %>