From 554aa0a95d52603630f8c5e71f7e445c3eb28900 Mon Sep 17 00:00:00 2001
From: Wen-Tien Chang
- <%= f.label attr["name"] %> - <%= f.send(attr["type"], "#{ua.key}_#{attr["key"]}" )%> -
+ <% if attr["locale"] %> ++ <%= f.label attr["name_#{I18n.locale}"] %> + <% if attr["type"] == "text_field" %> + + <% VALID_LOCALES.each do |locale| %> + <%= f.text_field "#{ua.key}_#{attr["key"]}_#{locale}" %>(<%= locale %>) + <% end -%> + + <% elsif attr["type"] == "select" %> + <%= f.select "#{ua.key}_#{attr["key"]}_#{I18n.locale}", attr["options_#{I18n.locale}"].to_a %> + <% end -%> +
+ <% else %> ++ <%= f.label attr["name"] %> + <% if attr["type"] == "text_field" %> + <%= f.text_field "#{ua.key}_#{attr["key"]}" %> + <% elsif attr["type"] == "select" %> + <%= f.select "#{ua.key}_#{attr["key"]}", attr["options"].to_a %> + <% end -%> +
+ <% end -%> <% end -%> <% end -%> diff --git a/lib/tasks/dev.rake b/lib/tasks/dev.rake index 5069986c..74dcae48 100644 --- a/lib/tasks/dev.rake +++ b/lib/tasks/dev.rake @@ -6,10 +6,13 @@ namespace :dev do User.create!( :email => 'ihower@rulingcom.com', :password => 'password', :password_confirmation => 'password', :use_attributes => ["teacher"] ) - UserAttribute.create!( :key => "teacher", :name => "Teacher", :attrs => [ { :name => "Name", :key => "name", :type => "text_field" }, { :name => "Title", :key => "title", :type => 'text_field' } ] ) + UserAttribute.create!( :key => "teacher", :name => "Teacher", :attrs => [ + { :name => "Name", :key => "name", :type => "text_field", :locale => false }, + { :name => "Title", :key => "title", :type => 'select', :options => [ ["Professor","1"], ["Associate Professor","2"], ["Doctor","3"] ], :locale => false } , + { :name_en => "Discipline", :name_zh_tw => "授課領域", :key => "discipline", :type => "text_field", :locale => true }, + { :name_en => "Category", :name_zh_tw => "類別", :key => "category", :type => 'select', :options_en => [ ["Class1","1"], ["Class2","2"] ], :options_zh_tw => [ ["類別一","1"], ["類別二","2"] ], :locale => true} + ]) - UserAttribute.create!( :key => "staff", :name => "Staff", :attrs => [ { :name => "Name", :key => "name", :type => "text_field" }, { :name => "Duty", :key => "duty", :type => 'text_field' } ] ) - [Announcement, Item, Snippet, Layout].each { |m| m.delete_all } Layout.create!( :name => 'root', :description => 'root', :content_zh_tw => File.open("#{RAILS_ROOT}/lib/template/root.layout.zh_tw").read, :content_en => File.open("#{RAILS_ROOT}/lib/template/root.layout.en").read)