Sha256: d498a1205cc844a9352f3b945586a249faa13f655774c5ceb495c10134cdfc78

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

module MegaBar
  module ApplicationHelper
    def sortable(column, title=nil)
      title ||= column.titleize
      css_class = column == sort_column ? "current #{sort_direction}" : nil
      direction = column == sort_column && sort_direction == 'asc' ? 'desc' : 'asc'
      link_to title, {:sort => column, :direction => direction}, class: css_class
    end

    def link_path(action = nil, id = nil)
      # application helper
      action ||= params[:action]
      case action
      when 'index' #untested
        url_for(controller: params[:controller].to_s,
        action:  params[:action],
        only_path: true)
      when 'new' 
        url_for(controller: params[:controller].to_s,
        action:  'new',
        only_path: true)
      when 'edit'  #untested
        url_for(controller: params[:controller].to_s,
        action:  'edit',
        :id=>id,#catch errors
        only_path: true)
      when 'show'  #untested
        url_for(controller: params[:controller].to_s,
          :id => id,
          action:  'show',
          only_path: true
        )
      else
        form_path = 'tbd'
      end
    end
    def pre_render
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mega_bar-0.0.1 app/helpers/mega_bar/application_helper.rb