external link

This commit is contained in:
Nicolas Bally 2011-07-08 17:39:59 +02:00
parent aad7659b0e
commit cc4bbc24e3
3 changed files with 93 additions and 0 deletions

View File

@ -0,0 +1,71 @@
# -*- encoding : utf-8 -*-
class Admin::ExternalLinksController < ApplicationController
before_filter :authenticate_admin!
layout "admin"
navigation :admins
def cible
@external_links = ExternalLink.all
render :layout => false
end
def new
@breadcrumb = [["liste des administrateurs", admin_admins_path],"Ajouter un administrateur"]
@external_link = ExternalLink.new
respond_to do |format|
format.js
end
end
def edit
@external_link = ExternalLink.find(params[:id])
end
def create
@external_link = ExternalLink.new(params[:external_link])
respond_to do |format|
if @external_link.save
flash[:notice] = "Le lien à été ajouté avec succès."
format.js
else
format.html { render :action => "new" }
format.js { render :action => "new" }
end
end
end
def update
@external_link = ExternalLink.find(params[:id])
respond_to do |format|
if @external_link.update_attributes(params[:external_link])
format.js
else
format.js { render :action => "edit" }
end
end
end
def destroy
@external_link = ExternalLink.find(params[:id])
@external_link.destroy
respond_to do |format|
format.js
end
end
end

View File

@ -0,0 +1,16 @@
class ExternalLink < ActiveRecord::Base
validates :url, :presence => true
def cible_name
"Lien externe : #{self.url}"
end
def cible_url
self.url
end
end

View File

@ -62,6 +62,12 @@ Pharma::Application.routes.draw do
namespace :admin do
root :to => "dashboard#index"
resources :folders
resources :external_links do
collection do
get :cible
end
end
resources :articles
resources :admins
resources :menus