Module: ApplicationHelper

Defined in:
lib/generators/squeezer/templates/app/helpers/application_helper.rb

Overview

Methods added to this helper will be available to all templates in the application.

Instance Method Summary collapse

Instance Method Details

#action_barObject



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/generators/squeezer/templates/app/helpers/application_helper.rb', line 51

def action_bar
  h={
   :show => [:index,:new,:edit,:historics,:destroy],
   :index =>[:new],
   :new => [:index],
   :edit => [:index,:show,:new,:historics,:destroy],
   :historics =>[:index,:show,:new,:edit,:destroy],
   :old => [:index,:show,:new,:historics]
  }
  bar=list_bar(h[action_name.to_sym])

  content_for :action_bar do
    bar
  end
end

#destroy_barObject



27
28
29
# File 'lib/generators/squeezer/templates/app/helpers/application_helper.rb', line 27

def destroy_bar
  "#{link_permitted "Borrar",:destroy,controller_name.to_sym,{:action=>:show,:id=>params[:id]}} "
end

#edit_barObject



35
36
37
# File 'lib/generators/squeezer/templates/app/helpers/application_helper.rb', line 35

def edit_bar
  "#{link_permitted "Editar",:edit,controller_name.to_sym,{:action=>:edit,:id=>params[:id]}} "
end

#historics_barObject



31
32
33
# File 'lib/generators/squeezer/templates/app/helpers/application_helper.rb', line 31

def historics_bar
  "#{link_permitted "Historico",:historics,controller_name.to_sym,{:action=>:historics,:id=>params[:id]}} "
end

#index_barObject



23
24
25
# File 'lib/generators/squeezer/templates/app/helpers/application_helper.rb', line 23

def index_bar
  "#{link_permitted "Ver Todos",:index,controller_name.to_sym,{:action=>:index}} "
end


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/generators/squeezer/templates/app/helpers/application_helper.rb', line 3

def link_permitted(*args)
  name = args.first
  
  action = args.second
  obj = args.third    
  options = args.fourth
  
  if permitted_to? action,obj
    if action == :destroy 
      link_to name,options,:confirm => 'Are you sure?', :method => :delete
    else
      link_to name,options
    end
  end
end

#list_bar(a) ⇒ Object



43
44
45
46
47
48
49
# File 'lib/generators/squeezer/templates/app/helpers/application_helper.rb', line 43

def list_bar(a)
  bar=""
  a.each {|x|
    bar +=eval(x.to_s+'_bar') 
  }
  return bar
end

#new_barObject



39
40
41
# File 'lib/generators/squeezer/templates/app/helpers/application_helper.rb', line 39

def new_bar
  "#{link_permitted "Nuevo",:new,controller_name.to_sym,{:action=>:new}} "
end

#show_barObject



19
20
21
# File 'lib/generators/squeezer/templates/app/helpers/application_helper.rb', line 19

def show_bar
  "#{link_permitted "Mostrar",:show,controller_name.to_sym,{:action=>:show,:id=>params[:id]}} "
end