fix deletes in journal paper

This commit is contained in:
Saurabh Bhatia 2014-07-10 14:52:06 +08:00
parent 70064bde29
commit adea371161
4 changed files with 9 additions and 4 deletions

View File

@ -2,9 +2,10 @@ class Admin::JournalPapersController < OrbitMemberController
include Admin::JournalPapersHelper include Admin::JournalPapersHelper
layout "member_plugin" layout "member_plugin"
before_action :set_journal_paper, only: [:show, :edit , :update, :destroy] before_action :set_journal_paper, only: [:show, :edit , :update]
before_action :get_plugins, only: [:index, :writing_journal_setting, :new, :create, :edit, :update] before_action :get_plugins, only: [:index, :writing_journal_setting, :new, :create, :edit, :update]
before_action :set_types, only: [:writing_journal_setting, :new, :edit, :create, :update] before_action :set_types, only: [:writing_journal_setting, :new, :edit, :create, :update]
before_action :find_journal_paper, only: [:destroy]
def index def index
@writing_journals = JournalPaper.all @writing_journals = JournalPaper.all
@ -179,6 +180,10 @@ class Admin::JournalPapersController < OrbitMemberController
@journal_paper = JournalPaper.find_by(uid: uid) @journal_paper = JournalPaper.find_by(uid: uid)
end end
def find_journal_paper
@journal_paper = JournalPaper.find_by(id: params[:id])
end
def journal_paper_attributes def journal_paper_attributes
params.require(:journal_paper).permit! rescue nil params.require(:journal_paper).permit! rescue nil
end end

View File

@ -30,7 +30,7 @@ class JournalPapersController < ApplicationController
"issue_no" => journal_paper.issue_no, "issue_no" => journal_paper.issue_no,
"form_to_start" => journal_paper.form_to_start, "form_to_start" => journal_paper.form_to_start,
"form_to_end" => journal_paper.form_to_end, "form_to_end" => journal_paper.form_to_end,
"language" => t(journal_paper.language), "language" => journal_paper.language,
"total_pages" => journal_paper.total_pages, "total_pages" => journal_paper.total_pages,
"keywords" => journal_paper.keywords, "keywords" => journal_paper.keywords,
"abstract" => journal_paper.abstract, "abstract" => journal_paper.abstract,

View File

@ -33,7 +33,7 @@ class JournalPaper
has_many :journal_paper_files, autosave: true, dependent: :destroy has_many :journal_paper_files, autosave: true, dependent: :destroy
accepts_nested_attributes_for :journal_paper_files accepts_nested_attributes_for :journal_paper_files
has_and_belongs_to_many :journal_paper_authors has_and_belongs_to_many :journal_paper_authors, dependent: :destroy
accepts_nested_attributes_for :journal_paper_authors accepts_nested_attributes_for :journal_paper_authors
has_and_belongs_to_many :journal_paper_author_types has_and_belongs_to_many :journal_paper_author_types

View File

@ -8,5 +8,5 @@ class JournalPaperFile
field :should_destroy, type: Boolean field :should_destroy, type: Boolean
mount_uploader :journal_file, AssetUploader mount_uploader :journal_file, AssetUploader
belongs_to :journal_paper belongs_to :journal_paper, dependent: :destroy
end end