Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Libraries

    acts_as_catalog 0.2

    Download button

    No screenshots available
    Downloads: 316  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    Fair (2.8/5)
    6 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Gunnar Wolf | More programs
    GPL / FREE
    April 14th, 2008, 14:34 GMT
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    acts_as_catalog description

    acts_as_catalog is a very simple plugin providing the common infrastructure for probably the most frequent auxiliar table ever.

    acts_as_catalog is a very simple plugin providing the common infrastructure for probably the most frequent auxiliar table ever: The catalog (a small table with only an ID and a name). It provides extensions for models, migrations and tests.

    Models

    A catalog is defined as a table with only a +name+ column of +string+ type, and with a unique index on it (this means, does not allow for duplicate values). This plugin allows you to specify your model definition as:

    def Mytable < ActiveRecord::Base
    acts_as_catalog
    belongs_to :some_other_table
    end


    A catalog is often accessed to populate i.e. drop-down selection or radio boxes, passing what is called +collections+ in Rails-speak. You will often want collections to be sorted by ID or by name, thus:

    collection = Mytable.collection_by_id

    another_col = Mytable.collection_by_name


    Migrations

    You can specify all the catalogs you need to create for a specific migration with a single instruction from inside your self.up method, by giving a list of catalog table names to create_catalogs:

    def self.up
    create_catalogs :countries, :states
    ...
    end


    Likewise, you can destroy the created catalogs in a single command. The drop_catalogs method will usually be the last thing you call in self.down:

    def self.up
    ...
    drop_catalogs :states, :countries
    end


    What's New in This Release:

    · Added the collection-handling class methods (collection_by_id, collection_by_name)



    Product's homepage

      


    TAGS:

    model extensions | database migration | database tests | database | catalog | migration

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM