Add UserAttribute model, suppose it will store user model want to use which attribute group
This commit is contained in:
parent
13065aa85a
commit
9f1de1b543
|
@ -3,4 +3,6 @@ class User
|
||||||
|
|
||||||
devise :authenticatable, :recoverable, :rememberable, :trackable
|
devise :authenticatable, :recoverable, :rememberable, :trackable
|
||||||
|
|
||||||
|
key :use_attributes
|
||||||
|
|
||||||
end
|
end
|
|
@ -0,0 +1,9 @@
|
||||||
|
class UserAttribute
|
||||||
|
|
||||||
|
include MongoMapper::Document
|
||||||
|
|
||||||
|
key :ident, String
|
||||||
|
key_i18n :name, String
|
||||||
|
key_i18n :attrs, Array
|
||||||
|
|
||||||
|
end
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th>Attrs</th>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>Email</th>
|
<th>Email</th>
|
||||||
<th>Action</th>
|
<th>Action</th>
|
||||||
|
@ -15,9 +16,13 @@
|
||||||
|
|
||||||
<% @users.each do |user| %>
|
<% @users.each do |user| %>
|
||||||
<tr>
|
<tr>
|
||||||
|
<td><%= user.use_attributes.join(",") %></td>
|
||||||
<td><%#= user.name %></td>
|
<td><%#= user.name %></td>
|
||||||
<td><%= user.email %></td>
|
<td><%= user.email %></td>
|
||||||
<td><%= link_to 'Edit', edit_panel_user_path(user) %> | <%= link_to 'Destroy', panel_user_path(user), :method => :delete %></td>
|
<td>
|
||||||
|
<%= link_to 'Show', panel_user_path(user) %>
|
||||||
|
<%= link_to 'Edit', edit_panel_user_path(user) %> |
|
||||||
|
<%= link_to 'Destroy', panel_user_path(user), :method => :delete %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
<% content_for :secondary do %>
|
||||||
|
<ul class="list">
|
||||||
|
<li><%= link_to t(:new_user, :scope => :panel), new_panel_user_path, :class => 'button positive' %></li>
|
||||||
|
</ul>
|
||||||
|
<% end -%>
|
||||||
|
|
||||||
|
<h1>Users panel</h1>
|
||||||
|
|
||||||
|
<%=h @user.name %>
|
||||||
|
<%=h @user.email %>
|
|
@ -2,7 +2,10 @@ namespace :dev do
|
||||||
|
|
||||||
task :build => :environment do
|
task :build => :environment do
|
||||||
User.delete_all
|
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 }
|
[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,
|
Layout.create!( :name => 'root', :description => 'root', :content_zh_tw => File.open("#{RAILS_ROOT}/lib/template/root.layout.zh_tw").read,
|
||||||
|
|
Loading…
Reference in New Issue