Skip to content
No description or website provided.
Ruby JavaScript
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Super List -

## in config/initializers/super_list.rb"Gender", {"M" => {:default => "Man", :amos => "M1"}, "F" => {:default => "Female", :amos => "M2"}}, :allow_blank => true)"Gender2", {"M" => "Man", "F" => "Female"}, :allow_blank => true, :use_i18n => false)

## in app/models/user.rb
class User < ActiveRecord::Base
  super_list :gender, 'Gender'
  super_list :gender2, 'Gender', :use_i18n => true
end => 'NF').valid?              => false => 'M').valid?               => true => 'F').gender(:default)     => 'Female' => 'F').gender(:amos)        => 'M2' => 'F').gender               => 'F' => 'Man').valid?             => true => 'Man').gender             => 'M' => 'Man').gender(:amos)      => 'M1'

user = => 'F', :gender2 => 'M')
user.gender2(:default)                     => "translation missing: en.Gender.Man"
user.gender2(:locale => "api")             => "translation missing: api.Gender.Man"

SuperList["Gender"].get_value("M").to_s    => "Man"
SuperList["Gender"].get_key("Man")         =>  "M"
SuperList["Gender1"].get_key("translation missing: en.Gender1.Female") => "F"
SuperList["Gender"].options               => {:use_i18n=>false, :i18n_scope=>"Gender", :allow_blank=>true}
SuperList["Gender"].keys                  => ["M", "F"]
SuperList["Gender"].values(:use_i18n => true, :locale => 'zh')
                                          => ["translation missing: zh.Gender1.Man", "translation missing: zh.Gender1.Female"]

assert_equal ["M","F"], SuperList["Gender"].map {|k,v| k }
assert_equal ["Man", "Female"], SuperList["Gender"].map {|k,v| v }

assert_equal ["M","F"], SuperList["Gender"].select_options {|k,v| v }
assert_equal ["Man", "Female"], SuperList["Gender"].select_options {|k,v| k }

Please refer test file for more examples.

Contributing to super_list

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet

  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it

  • Fork the project

  • Start a feature/bugfix branch

  • Commit and push until you are happy with your contribution

  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.

  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.


Copyright © 2011 Jinzhu. See LICENSE.txt for further details.

Something went wrong with that request. Please try again.