orbit-basic/app/controllers/desktop/co_authors_controller.rb

72 lines
1.8 KiB
Ruby
Raw Normal View History

class Desktop::CoAuthorsController < ApplicationController
def index
@co_authors = CoAuthor.where(name_id: current_user.id)
respond_to do |format|
format.html { render :layout => false}
format.json { render json: @co_authors }
end
end
def show
@co_author = CoAuthor.find(params[:id])
respond_to do |format|
format.html { redirect_to desktop_co_authors_url, :layout => false }
format.json { render json: @co_author }
end
end
def new
@co_author = CoAuthor.new
respond_to do |format|
format.html { render :layout => false}
end
end
def edit
@co_author = CoAuthor.find(params[:id])
respond_to do |format|
format.html { render :layout => false}
end
end
def create
@co_author = CoAuthor.new(params[:co_author])
@co_author.name_id= current_user.id
respond_to do |format|
if @co_author.save
format.html { redirect_to desktop_co_authors_path, :layout => false, notice: 'CoAuthor was successfully created.' }
else
format.html { render action: "new", :layout => false}
end
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
end
end
def delete
@co_author = CoAuthor.find(params[:id])
@co_author.destroy
respond_to do |format|
format.html { redirect_to desktop_co_authors_url, :layout => false }
format.json { head :no_content }
end
end
end