Commit 2e080c03 authored by 神楽坂玲奈's avatar 神楽坂玲奈

PM初步,不能用

git-svn-id: http://glupx.googlecode.com/svn/trunk/Reliz@86 189f022a-1064-8ae2-3e6f-c4a67275c50b
parent 43b7cbd0
......@@ -2,7 +2,8 @@ class PmsController < ApplicationController
# GET /pms
# GET /pms.xml
def index
@pms = Pm.all
@actions = [:pm]
@pms = Pm.find_all_by_to_user_id @corrent_user.id
respond_to do |format|
format.html # index.html.erb
......@@ -14,6 +15,10 @@ class PmsController < ApplicationController
# GET /pms/1.xml
def show
@pm = Pm.find(params[:id])
if @pm.from_user != @corrent_user && @pm.to_user != @corrent_user
return render :text => "pm unexisted"
end
#@pms = PM.find(:all, ["from_user_id =? or to_user_id =?", @corrent_user.id])
respond_to do |format|
format.html # show.html.erb
......@@ -24,6 +29,7 @@ class PmsController < ApplicationController
# GET /pms/new
# GET /pms/new.xml
def new
@actions = [:new_pm]
@pm = Pm.new
respond_to do |format|
......@@ -40,8 +46,9 @@ class PmsController < ApplicationController
# POST /pms
# POST /pms.xml
def create
params[:pm][:to_user] = User.find_by_name params[:pm][:to_user][:name]
@pm = Pm.new(params[:pm])
@pm.from_user = @corrent_user
respond_to do |format|
if @pm.save
format.html { redirect_to(@pm, :notice => 'Pm was successfully created.') }
......
class Board < ActiveRecord::Base
belongs_to :superboard, :class_name => :"::Board"
has_many :subboards, :foreign_key => :superboard_id, :class_name => :"::Board"
belongs_to :superboard, :class_name => "::Board"
has_many :subboards, :foreign_key => :superboard_id, :class_name => "::Board"
has_many :topics, :foreign_key => :category_id
has_many :posts, :through =>:topics
default_scope order(:displayorder)
......
class Pm < ActiveRecord::Base
belongs_to :from_user, :class_name => :"::User", :foreign_key => :from_user_id
belongs_to :to_user, :class_name => :"::User", :foreign_key => :to_user_id
belongs_to :from_user, :class_name => "::User", :foreign_key => :from_user_id
belongs_to :to_user, :class_name => "::User", :foreign_key => :to_user_id
validates :to_user, :presence => true
end
<% @pms.each do |pm| %>
<tr>
<td><%= pm.user %></td>
<td><%= pm.user %></td>
<td><%= pm.from_user %></td>
<td><%= pm.to_user %></td>
<td><%= pm.content %></td>
<td><%= link_to 'Show', pm %></td>
<td><%= link_to 'Edit', edit_pm_path(pm) %></td>
......
......@@ -4,17 +4,23 @@
<h2><%= pluralize(@pm.errors.count, "error") %> prohibited this pm from being saved:</h2>
<ul>
<% @pm.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
<% @pm.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :user_id %>
<%= f.text_field :user_id %>
<%= f.label :to_user %>
<%= text_field_tag 'pm[to_user][name]' %>
</div>
<div class="field">
<%= f.label :content %>
<%= render 'topics/editor_lite', :name => "pm[content]" %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<%= render 'topics/editor_lite', :name => "pm[content]" %>
<% end %>
<%= link_to 'Back', pms_path %>
<p id="notice"><%= notice %></p>
<p>
<b>User:</b>
<%= @pm.user %>
</p>
<p>
<b>User:</b>
<%= @pm.user %>
</p>
<p>
<b>Content:</b>
<%= @pm.content %>
</p>
<%= link_to 'Edit', edit_pm_path(@pm) %> |
<%= link_to 'Back', pms_path %>
<ul class="pm_list">
<% @pms.each do |pm| %>
<li id="pm_<%= pm.id %>" class="s_clear ">
<a href="space.php?uid=7721" target="_blank" class="avatar"><img src="http://www.touhou.cc/ucenter/avatar.php?uid=7721&amp;size=small"></a>
<p class="cite">
<cite><a href="space.php?uid=7721" target="_blank">lastworm</a></cite>2010-8-23 20:55</p>
<div class="summary">
求你的签名的完整图~~</div>
<p class="more"><a href="pm.php?uid=7721&amp;filter=privatepm&amp;daterange=5#new" class="to">查看消息</a></p>
<span class="action">
<input name="uid[]" class="checkbox" type="checkbox" value="7721">
<a href="pm.php?action=del&amp;uid=7721&amp;filter=privatepm" id="pmd_2799" onclick="deletepm(this, 2799);return false;" class="delete" title="删除">删除</a>
</span>
</li><li id="pm_157" class="s_clear colplural">
<a href="space.php?uid=316" target="_blank" class="avatar"><img src="http://www.touhou.cc/ucenter/avatar.php?uid=316&amp;size=small"></a>
<p class="cite">
<cite><a href="space.php?uid=316" target="_blank">祈愿之湖</a></cite>2010-1-16 13:43</p>
<div class="summary">
什么事情都是先抱怨的你自然不能体会菠萝的辛苦,你以为自己掏钱弄一个论坛容易嘛?你以为每天晚上熬夜修复论坛BUG容易嘛?你知道这个论坛升级了几次嘛?你知道菠萝他是为啥干这个的嘛?不知道的话,先好好学习下再说 ...</div>
<p class="more"><a href="pm.php?uid=316&amp;filter=privatepm&amp;daterange=5#new" class="to">查看消息</a></p>
<span class="action">
<input name="uid[]" class="checkbox" type="checkbox" value="316">
<a href="pm.php?action=del&amp;uid=316&amp;filter=privatepm" id="pmd_157" onclick="deletepm(this, 157);return false;" class="delete" title="删除">删除</a>
</span>
</li></ul>
\ No newline at end of file
......@@ -216,8 +216,14 @@ zh-CN:
last_word_connector: ", "
select:
prompt: "请选择"
activerecord:
models:
user: 用户
attributes:
pm:
to_user: "收件人"
content: "正文"
errors:
template: # ~ 2.3.5 backward compatible
header:
......
class DemoData < ActiveRecord::Migration
def self.up
=begin
Board.create :id => 1,
:superboard_id => 0,
:name => "综合讨论中心"
......@@ -102,7 +101,6 @@ class DemoData < ActiveRecord::Migration
:topic_lock => true
Role.create :id => 5,
:name => "普通用户"
=end
Role.create :id => 6,
:name => "游客"
......
class CreatePms < ActiveRecord::Migration
def self.up
create_table :pms do |t|
t.references :user
t.references :from_user
t.text :content
t.references :from_user, :null => false
t.references :to_user, :null => false
t.boolean :read, :null => false, :default => false
t.text :content, :null => false
t.timestamps
end
......
......@@ -10,7 +10,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20111042972029) do
ActiveRecord::Schema.define(:version => 20111052032430) do
create_table "boards", :force => true do |t|
t.string "name", :default => "", :null => false
......@@ -74,9 +74,10 @@ ActiveRecord::Schema.define(:version => 20111042972029) do
end
create_table "pms", :force => true do |t|
t.integer "user_id"
t.integer "from_user_id"
t.text "content"
t.integer "from_user_id", :null => false
t.integer "to_user_id", :null => false
t.boolean "read", :default => false, :null => false
t.text "content", :null => false
t.datetime "created_at"
t.datetime "updated_at"
end
......@@ -130,10 +131,11 @@ ActiveRecord::Schema.define(:version => 20111042972029) do
create_table "users", :force => true do |t|
t.string "name", :null => false
t.string "nickname", :default => "", :null => false
t.string "password", :null => false
t.string "email", :default => "", :null => false
t.integer "role_id", :default => 0, :null => false
t.string "nickname", :default => "", :null => false
t.text "signature", :null => false
t.boolean "locked", :default => false, :null => false
t.string "regip", :default => "", :null => false
t.string "lastloginip", :default => "", :null => false
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment