Sha256: c836427a3694c84b2e139e6a410b0dac12520aff4c54c02195a19eeee9a389e6
Contents?: true
Size: 1.35 KB
Versions: 3
Compression:
Stored size: 1.35 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 == advantage acts_as_wuid :acts_as_tree => true == 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ploymorphic_wuid-0.4.1 | README.rdoc |
ploymorphic_wuid-0.2.1 | README.rdoc |
ploymorphic_wuid-0.2.0 | README.rdoc |