This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
orbit-4-1/app/controllers/admin/links_controller.rb

71 lines
1.4 KiB
Ruby

class Admin::LinksController < Admin::ItemsController
def show
@item ||= Link.find(params[:id])
end
def new
@item = Link.new
@item.parent = Page.find(params[:parent_id]) rescue nil
end
def edit
@item = Link.find(params[:id])
end
def create
@item = Link.new(params[:link])
if @item.save
flash.now[:notice] = t('create.success.link')
respond_to do |format|
format.html {
redirect_to admin_link_url(@item)
}
format.js {}
end
else
flash.now[:error] = t('create.error.link')
render :action => "new"
end
end
def update
@item = Link.find(params[:id])
if @item.update_attributes(params[:link])
flash.now[:notice] = t('update.success.link')
respond_to do |format|
format.html {
redirect_to admin_link_url(@item)
}
format.js {}
end
else
flash.now[:error] = t('update.error.link')
render :action => "edit"
end
end
def destroy
@item = Link.find(params[:id])
@item.destroy
respond_to do |format|
format.html {
redirect_to admin_items_url
}
format.js {}
end
end
def delete
@item = Link.find(params[:id])
@item.destroy
respond_to do |format|
format.html {}
format.js { @item = @item.parent }
end
end
end