Skip to content

Quick and painless action links for your rails applications

License

Notifications You must be signed in to change notification settings

biola/action_links

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Action_Links automatically includes action links (show, edit, destroy) based on the current page and user roles/permissions.

Installation

Add the following to your Gemfile

gem "action_links"

From the command line

> bundle install

Action Links is built to work with Declarative Authorization

Configuration

Configuration is optional. Everything will work out of the box.

ActionLinks.configure do |config|
  @bootstrap_action_classes = { :show => 'btn', :edit => 'btn', :destroy => 'btn btn-danger' }
  @bootstrap_action_icons = { :show => 'icon-eye-open', :edit => 'icon-pencil', :destroy => 'icon-remove icon-white' }
  @action_icons = { :show => 'eye-open', :edit => 'pencil', :destroy => 'remove' }
end

Usage

  • Basic Usage

    action_links @user
    
  • Include actions

    action_links @user, :include => [:download]
    
  • Exclude actions

    action_links @user, :exclude => [:edit, :destroy]
    
  • Pass in block

    action_links @user do
      link_to "Hello World", dashboard_path
    end
    
  • Bootstrap buttons. See configuration to customize button types and icons.

    bootstrap_action_links @user
    
  • Namespaced objects

    action_links [:manage, @product]
    
  • Return just the link with optional parameters

    =action_link :edit, @event
    // or more advanced
    =action_link :clone, @event, link_wrapper: :li, url: url_for([:clone, @event]), icon: 'copy', text: 'Copy', class: 'btn'
  • You can even pass in custom attributes with the :html tag

    =action_link :clone, @event, class: 'btn', html: { id: 'super_cool_clone_button' }
    // NOTE: if you define 'class' in the :html hash, it will overwrite the default class,
    //       otherwise you can define class outside of the :html hash like in the above example 
    //       and it will be added to the default value.

About

Quick and painless action links for your rails applications

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages