fixed add journal and co-author curd problem, but have redirect problem...
This commit is contained in:
1 parent
bb69a059e8
commit
9e400e6e6a
7 files changed
+20
-45
No files matched your search
@@ -36,24 +36,20 @@ class Desktop::CoAuthorsController < ApplicationController
|
||||
@co_author = CoAuthor.new(params[:co_author])
|
||||
@co_author.name_id= current_user.id
|
||||
|
||||
if @writing_journal.save
|
||||
render :json => {success:true, msg: "Paper successfully saved!"}.to_json
|
||||
if @co_author.save
|
||||
render json: {success:true, msg: "Co-author successfully saved!"}.to_json
|
||||
else
|
||||
render :json => {success:false, msg: "Saving failed!"}
|
||||
render json: {success: false, msg: @co_author.errors.full_messages}.to_json
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@co_author = CoAuthor.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
if @co_author.update_attributes(params[:co_author])
|
||||
format.html { redirect_to desktop_co_authors_url, notice: 'CoAuthor was successfully updated.' }
|
||||
format.json { head :no_content }
|
||||
else
|
||||
format.html { render action: "edit" }
|
||||
format.json { render json: @co_author.errors, status: :unprocessable_entity }
|
||||
end
|
||||
if @co_author.update_attributes(params[:co_author])
|
||||
render json: {success:true, msg: "Co-author successfully update!"}.to_json
|
||||
else
|
||||
render json: {success: false, msg: @co_author.errors.full_messages}.to_json
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Desktop::JournalPagesController < ApplicationController
|
||||
#before_filter :check_for_cancel, :only => [:create, :update]
|
||||
|
||||
def index
|
||||
@writing_journal = WritingJournal.where(create_user_id: current_user.id)
|
||||
@@ -35,14 +36,14 @@ class Desktop::JournalPagesController < ApplicationController
|
||||
end
|
||||
|
||||
def create
|
||||
params[:writing_journal][:create_user_id] = current_user.id
|
||||
@writing_journal = WritingJournal.new(params[:writing_journal])
|
||||
params[:writing_journal][:create_user_id] = current_user.id
|
||||
@writing_journal = WritingJournal.new(params[:writing_journal])
|
||||
|
||||
if @writing_journal.save
|
||||
render json: {success: true, msg: "Paper successfully saved!"}.to_json
|
||||
else
|
||||
render json: {success: false, msg: "Saving failed!"}.to_json
|
||||
end
|
||||
if @writing_journal.save
|
||||
render json: {success: true, msg: "Paper successfully saved!"}.to_json
|
||||
else
|
||||
render json: {success: false, msg: @writing_journal.errors.full_messages}.to_json
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@@ -52,7 +53,7 @@ class Desktop::JournalPagesController < ApplicationController
|
||||
if @writing_journal.update_attributes(params[:writing_journal])
|
||||
render json: {success: true, msg: "Paper successfully saved!"}.to_json
|
||||
else
|
||||
render json: {success: false, msg: "Saving failed!"}.to_json
|
||||
render json: {success: false, msg: @writing_journal.errors.full_messages}.to_json
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user