add rough user attributes API
This commit is contained in:
1 parent
29ee4585b2
commit
a40b117fbe
6 files changed
+32
-11
No files matched your search
@@ -13,6 +13,7 @@ class Panel::UsersController < ApplicationController
|
||||
|
||||
def new
|
||||
@user = User.new
|
||||
@user_attributes = UserAttribute.all
|
||||
end
|
||||
|
||||
def create
|
||||
@@ -26,6 +27,7 @@ class Panel::UsersController < ApplicationController
|
||||
|
||||
def edit
|
||||
@user = User.find(params[:id])
|
||||
@user_attributes = UserAttribute.all
|
||||
end
|
||||
|
||||
def update
|
||||
|
||||
+12
-2
@@ -3,6 +3,16 @@ class User
|
||||
|
||||
devise :authenticatable, :recoverable, :rememberable, :trackable
|
||||
|
||||
key :use_attributes
|
||||
|
||||
# key :use_attributes
|
||||
|
||||
def method_missing(method)
|
||||
safe_read(method)
|
||||
end
|
||||
|
||||
def safe_read(key)
|
||||
self[key]
|
||||
rescue MongoMapper::KeyNotFound
|
||||
return ""
|
||||
end
|
||||
|
||||
end
|
||||
@@ -2,7 +2,7 @@ class UserAttribute
|
||||
|
||||
include MongoMapper::Document
|
||||
|
||||
key :ident, String
|
||||
key :key, String
|
||||
key_i18n :name, String
|
||||
key_i18n :attrs, Array
|
||||
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
<p>
|
||||
<%= label_tag :name %>
|
||||
<%= text_field_tag "user[name]" %>
|
||||
</p>
|
||||
<% @user_attributes.each do |ua| %>
|
||||
<h3><%= ua.name %></h3>
|
||||
|
||||
<% ua.attrs.each do |attr| %>
|
||||
<p>
|
||||
<%= f.label attr["name"] %>
|
||||
<%= f.send(attr["type"], "#{ua.key}_#{attr["key"]}" )%>
|
||||
</p>
|
||||
<% end -%>
|
||||
<% end -%>
|
||||
|
||||
<p>
|
||||
<%= f.label :email %>
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<% @users.each do |user| %>
|
||||
<tr>
|
||||
<td><%= user.use_attributes.join(",") %></td>
|
||||
<td><%#= user.name %></td>
|
||||
<td><%= user.name %></td>
|
||||
<td><%= user.email %></td>
|
||||
<td>
|
||||
<%= link_to 'Show', panel_user_path(user) %>
|
||||
|
||||
Reference in new issue
Block a user