Sha256: acb613ddd7558b63dc3dda27f3abcb7ca897b2a43fdd35572239bfffde44d7d5
Contents?: true
Size: 1.62 KB
Versions: 7
Compression:
Stored size: 1.62 KB
Contents
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper 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 def show_bar "#{link_permitted "Mostrar",:show,controller_name.to_sym,{:action=>:show,:id=>params[:id]}} " end def index_bar "#{link_permitted "Ver Todos",:index,controller_name.to_sym,{:action=>:index}} " end def destroy_bar "#{link_permitted "Borrar",:destroy,controller_name.to_sym,{:action=>:show,:id=>params[:id]}} " end def historics_bar "#{link_permitted "Historico",:historics,controller_name.to_sym,{:action=>:historics,:id=>params[:id]}} " end def edit_bar "#{link_permitted "Editar",:edit,controller_name.to_sym,{:action=>:edit,:id=>params[:id]}} " end def new_bar "#{link_permitted "Nuevo",:new,controller_name.to_sym,{:action=>:new}} " end def list_bar(a) bar="" a.each {|x| bar +=eval(x.to_s+'_bar') } return bar end 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 end
Version data entries
7 entries across 7 versions & 1 rubygems