Sha256: f98bfd70eba77bbb65fc73077094e2d30c535fb5e054cc78c9bc39b1667596ef
Contents?: true
Size: 1.3 KB
Versions: 2
Compression:
Stored size: 1.3 KB
Contents
= ploymorphic_wuid Say you want you set an uniq id to an object (whatever it is), and get the object through the id, for example get an object's versions: /wuid/:id/versions return the object through ploymorphic: obj = Wuid.find(params[:id]).wuidable == Migration class CreateWuids < ActiveRecord::Migration def self.up create_table :wuids do |t| t.integer :wuidable_id t.string :wuidable_type t.integer :reference_to #optional t.timestamps end end def self.down drop_table :wuids end end == Settings in the environment.rb config.gem "ploymorphic_wuid" in your model class Book < ActiveRecord::Base acts_as_wuid end that's all == Usage return the object: obj = Wuid.find(params[:wuid]).wuidable get an object's wuid: obj.wid == Note on Patches/Pull Requests * Fork the project. * Make your feature addition or bug fix. * Add tests for it. This is important so I don't break it in a future version unintentionally. * Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull) * Send me a pull request. Bonus points for topic branches. == Copyright Copyright (c) 2010 tim.teng. See LICENSE for details.
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ploymorphic_wuid-0.4.3 | README.rdoc |
ploymorphic_wuid-0.4.2 | README.rdoc |