Class Admin::LinksController
In: app/controllers/admin/links_controller.rb
Parent: Admin::BaseController

Methods

Public Instance methods

[Source]

    # File app/controllers/admin/links_controller.rb, line 73
73:   def auto_complete_for_link_tag_list_es
74:     auto_complete_for_tag_list(params[:link][:tag_list_es])
75:     if @tags.length > 0
76:       render :inline => "<%= content_tag(:ul, @tags.map {|t| content_tag(:li, t.nombre)}) %>"
77:     else
78:       render :nothing => true
79:     end    
80:   end

[Source]

    # File app/controllers/admin/links_controller.rb, line 39
39:   def create
40:     @link = Link.new(params[:link])
41:     if @link.save
42:       flash[:notice] = "El enlace se ha creado correctamente"
43:       redirect_to admin_links_path
44:     else
45:       render :action => "new"
46:     end
47:   end

[Source]

    # File app/controllers/admin/links_controller.rb, line 63
63:   def destroy
64:     @link = Link.find(params[:id])
65:     if @link.destroy
66:       flash[:notice] = "El enlace se ha eliminado correctamente"
67:     else
68:       flash[:error] = "El enlace no ha podido eliminarse"
69:     end
70:     redirect_to admin_links_path
71:   end

[Source]

    # File app/controllers/admin/links_controller.rb, line 49
49:   def edit
50:     @link = Link.find(params[:id])
51:   end

[Source]

    # File app/controllers/admin/links_controller.rb, line 5
 5:   def index    
 6:     @sort_order = params[:sort] ||  "update"
 7:     
 8:     case @sort_order
 9:     when "update"
10:       order = "updated_at DESC, title_es, published_at DESC"
11:     when "publish"
12:       order = "published_at DESC, title_es, updated_at DESC"
13:     when "title"
14:       order = "lower(tildes(title_es)), published_at DESC, updated_at DESC"
15:     end
16:     
17:     conditions = []
18:     if params[:q].present?
19:       conditions << "lower(tildes(coalesce(title_es, '') || ' ' || coalesce(title_eu, ''))) like '%#{params[:q].tildes.downcase}%'"
20:     end
21: 
22:     set_current_tab    
23:     
24:     @links = Link.paginate :page => params[:page], :per_page => 20, 
25:       :order => order,
26:       :conditions => conditions.join(' AND ')
27: 
28:     @title = "Enlaces"
29:   end

[Source]

    # File app/controllers/admin/links_controller.rb, line 35
35:   def new
36:     @link = Link.new
37:   end

[Source]

    # File app/controllers/admin/links_controller.rb, line 31
31:   def show
32:     @link = Link.find(params[:id])
33:   end

[Source]

    # File app/controllers/admin/links_controller.rb, line 53
53:   def update
54:     @link = Link.find(params[:id])
55:     if @link.update_attributes(params[:link])
56:       flash[:notice] = "El enlace se ha actualizado correctamente"
57:       redirect_to admin_link_path(@link)
58:     else
59:       render :action => "edit"
60:     end
61:   end

[Validate]