Giter Site home page Giter Site logo

archdiocese-of-new-orleans / rails_admin_tag_list Goto Github PK

View Code? Open in Web Editor NEW

This project forked from goldenowlasia/rails_admin_tag_list

0.0 1.0 0.0 81 KB

ActsAsTaggableOn tag_list field factory for rails_admin

License: MIT License

Ruby 57.02% Haml 42.98%

rails_admin_tag_list's Introduction

Introduction

Greate rails_admin gem does not work with another great gem - acts_as_taggable_on, because rails_admin knows nothing about the virtual attributes *_list (tag_list, skill_list etc.), which created by acts_as_taggable_on for display and edit tags.

This problem is solved with rails_admin_tag_list gem.

Installation

In your Gemfile:

gem 'rails_admin'
gem 'rails_admin_tag_list'

and run:

$ bundle install

Usage and Configuration

rails_admin_tag_list by default does the following:

  1. Register new field type TagList for rails_admin
  2. Finds acts_as_taggable_on virtual attributes (*_list - tag_list, skill_list etc.) and adds them to RailsAdmin.config

There is your model:

class Player < ActiveRecord::Base
  attr_accessible :name
  attr_accessible :tag_list, :skill_list

  acts_as_taggable
  acts_as_taggable_on :skills
end

Note that tag_list (skill_list, etc.) attribute should be available for mass-assignment by rails_admin users.

Since Rails 3.2.3 config.active_record.whitelist_attributes option is true by default; this means that you should put tag_list (skill_list, etc.) attribute in the white list, like in example above:

attr_accessible :tag_list, :skill_list

edit field view

In addition to default field view (named form_tag_list) this gem provides two custom views tag_list_with_suggestions and tag_list_with_autocomplete. To enable any of them specify partial name:

RailsAdmin.config do |config|
  config.model Player do
    edit do
      fields_of_type :tag_list do
        partial 'tag_list_with_suggestions'
        
        # the option sets max count of suggestions (default is 100); set -1 to abolish the limit
        ratl_max_suggestions -1
      end
    end
  end
end

You can do with tag_list fields whatever what allows to do rails_admin:

rename label

RailsAdmin.config do |config|
  config.model Player do
    edit do
      field :tag_list do
        label "Tags"
      end
      field :skill_list
    end
  end
end

hide all tag_list fields

RailsAdmin.config do |config|
  config.model Player do
    edit do
      fields_of_type :tag_list do
        hide
      end
    end
  end
end

reassing partial

RailsAdmin.config do |config|
  config.model Player do
    edit do
      fields_of_type :tag_list do
        partial 'awesome_tag_list'
      end
    end
  end
end

Create you custom partial and put it to app/views/rails_admin/main/ in your own project folder

rails_admin_tag_list's People

Contributors

kryzhovnik avatar michaek avatar michele avatar neilang avatar billguy avatar emoreth avatar lloydpick avatar thethanghn avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.