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

51 lines
1012 B
Ruby

class Admin::LinksController < ApplicationController
layout "admin"
before_filter :authenticate_user!
before_filter :find_parent_item
def show
#TODO
end
def new
@link = Link.new
@link.is_published = true
@link.parent_name = @parent_item.name
end
def edit
@link = Link.find(params[:id])
end
def create
@link = Link.new(params[:link])
if @link.save
flash[:notice] = 'Link was successfully created.'
redirect_to admin_items_url( :parent_name => @link.parent_name )
else
render :action => "new"
end
end
def update
@link = Link.find(params[:id])
if @link.update_attributes(params[:link])
flash[:notice] = 'Link was successfully updated.'
redirect_to admin_items_url( :parent_name => @link.parent_name )
else
render :action => "edit"
end
end
def destroy
@link = Link.find(params[:id])
@link.destroy
redirect_to admin_items_url( :parent_name => @link.parent_name )
end
end