add back buton in relation page

This commit is contained in:
Rueshyna 2012-12-05 18:24:50 +08:00
parent 476041510c
commit 270644a959
3 changed files with 8 additions and 5 deletions

View File

@ -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("<br />")
error_msg = @co_author_relation.errors.full_messages.join("<br />")
render json: {success: false, msg: error_msg}.to_json
end
end

View File

@ -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" %>

View File

@ -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 %>