fixed co-author relation bug....
This commit is contained in:
		
							parent
							
								
									4ebbd7cb5a
								
							
						
					
					
						commit
						00c8bca957
					
				|  | @ -27,8 +27,17 @@ class Desktop::CoAuthorRelationsController < ApplicationController | ||||||
|   def destroy |   def destroy | ||||||
|     @co_author_relation = CoAuthorRelation.find(params[:id]) |     @co_author_relation = CoAuthorRelation.find(params[:id]) | ||||||
|     @co_author_relation.destroy |     @co_author_relation.destroy | ||||||
|     #reset_co_author_relation @co_author_relation |     reset_co_author_relation | ||||||
| 
 | 
 | ||||||
|     render :json => {success: true, msg: "deleted successfully!"} |     render :json => {success: true, msg: "deleted successfully!"} | ||||||
|   end |   end | ||||||
|  | 
 | ||||||
|  |   private | ||||||
|  | 
 | ||||||
|  |   def reset_co_author_relation | ||||||
|  |     co_author = CoAuthor.where(co_author_relations_id: @co_author_relation.id) | ||||||
|  |     co_author.map do |c| | ||||||
|  |       c.update_attributes(co_author_relations_id: nil) | ||||||
|  |     end | ||||||
|  |   end | ||||||
| end | end | ||||||
|  |  | ||||||
|  | @ -1,8 +1,2 @@ | ||||||
| module Desktop::CoAuthorRelationsHelper | module Desktop::CoAuthorRelationsHelper | ||||||
|   def reset_co_author_relation relation |  | ||||||
|     co_author = CoAuthor.where(co_author_relations_id: relation) |  | ||||||
|     co_author.map do |c| |  | ||||||
|       co_author.update_attributes(co_author_relations_id: nil) |  | ||||||
|     end |  | ||||||
|   end |  | ||||||
| end | end | ||||||
|  |  | ||||||
|  | @ -1,6 +1,4 @@ | ||||||
| <%# @co_author_relations.each do |co_author_relation| %> |  | ||||||
|   <tr> |   <tr> | ||||||
|     <td><%= show_form.relation %></td> |     <td><%= co_author_relation.relation %></td> | ||||||
|     <td><%= link_to 'Destroy', desktop_co_author_relation_path(show_form), confirm: 'Are you sure?', method: :delete, :class=>"bt-delete" %></td> |     <td><%= link_to 'Destroy', desktop_co_author_relation_path(co_author_relation), confirm: 'Are you sure?', method: :delete, :class=>"bt-delete" %></td> | ||||||
|   </tr> |   </tr> | ||||||
| <%# end %> |  | ||||||
|  |  | ||||||
|  | @ -12,6 +12,8 @@ | ||||||
|   </tr> |   </tr> | ||||||
| </thead> | </thead> | ||||||
| <tbody> | <tbody> | ||||||
|  <%= render :partial => 'show_form', :collection => @co_author_relations %>  |   <% @co_author_relations.each do |co_author_relation| %> | ||||||
|  |     <%= render :partial => 'show_form', locals: {:co_author_relation => co_author_relation} %> | ||||||
|  |   <% end %> | ||||||
| </tbody> | </tbody> | ||||||
| </table> | </table> | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue