diff --git a/app/models/user.rb b/app/models/user.rb index 5ce3f0d8..3cd89648 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -3,4 +3,6 @@ class User devise :authenticatable, :recoverable, :rememberable, :trackable + key :use_attributes + end \ No newline at end of file diff --git a/app/models/user_attribute.rb b/app/models/user_attribute.rb new file mode 100644 index 00000000..92e8aba3 --- /dev/null +++ b/app/models/user_attribute.rb @@ -0,0 +1,9 @@ +class UserAttribute + + include MongoMapper::Document + + key :ident, String + key_i18n :name, String + key_i18n :attrs, Array + +end \ No newline at end of file diff --git a/app/views/panel/users/index.html.erb b/app/views/panel/users/index.html.erb index 4fcdbd68..0065539a 100644 --- a/app/views/panel/users/index.html.erb +++ b/app/views/panel/users/index.html.erb @@ -8,16 +8,21 @@ - + + <% @users.each do |user| %> + - + <% end %>
NameAttrsName Email Action
<%= user.use_attributes.join(",") %> <%#= user.name %> <%= user.email %><%= link_to 'Edit', edit_panel_user_path(user) %> | <%= link_to 'Destroy', panel_user_path(user), :method => :delete %> + <%= link_to 'Show', panel_user_path(user) %> + <%= link_to 'Edit', edit_panel_user_path(user) %> | + <%= link_to 'Destroy', panel_user_path(user), :method => :delete %>
diff --git a/app/views/panel/users/show.html.erb b/app/views/panel/users/show.html.erb new file mode 100644 index 00000000..fb30564f --- /dev/null +++ b/app/views/panel/users/show.html.erb @@ -0,0 +1,10 @@ +<% content_for :secondary do %> + +<% end -%> + +

Users panel

+ +<%=h @user.name %> +<%=h @user.email %> \ No newline at end of file diff --git a/lib/tasks/dev.rake b/lib/tasks/dev.rake index 90aa3de7..71809b86 100644 --- a/lib/tasks/dev.rake +++ b/lib/tasks/dev.rake @@ -2,7 +2,10 @@ namespace :dev do task :build => :environment do User.delete_all - User.create!( :email => 'ihower@rulingcom.com', :password => 'password', :password_confirmation => 'password' ) + User.create!( :email => 'ihower@rulingcom.com', :password => 'password', :password_confirmation => 'password', :use_attributes => ["teacher"] ) + + UserAttribute.create!( :ident => "teacher", :name => "Teacher", :attrs => [ "name" => { :type => 'text_field', :width => 100 }, + "title" => { :type => 'text_field', :width => 100 } ] ) [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,