Commit 0de03d13 authored by 神楽坂玲奈's avatar 神楽坂玲奈

临时提交

parent 36d7a8cf
......@@ -4,6 +4,8 @@ class Post < ActiveRecord::Base
has_many :comments
has_many :attachments
accepts_nested_attributes_for :attachments
validates :content, :presence => true
def user
super || User::Guest
end
......
......@@ -4,6 +4,8 @@ class Topic < ActiveRecord::Base
belongs_to :board, :foreign_key => :category_id
has_many :posts
accepts_nested_attributes_for :posts
validates :name, :presence => true
default_scope where(:deleted => false)
self.per_page = 20
......
......@@ -8,10 +8,8 @@ class User < ActiveRecord::Base
has_many :wins, :class_name => "Duel", :foreign_key => :winner_id
belongs_to :role
validates :name, :presence => true,
:length => {:minimum => 1, :maximum => 254},
:uniqueness => {:case_sensitive => false}
validates :email, :presence => true,
:length => {:minimum => 3, :maximum => 254},
:uniqueness => {:case_sensitive => false},
:format => {:with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i}
has_many :topics
......
<%= form_for(@post, :html => { :multipart => true }) do |f| %>
<% if @post.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:</h2>
<h2><%=t 'activerecord.errors.template.header', :count => @post.errors.size, :model => @post.class.model_name.human %></h2>
<h4><%=t 'activerecord.errors.template.body', :count => @post.errors.size %></h4>
<ul>
<% @post.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
......
<%= form_for(@topic) do |f| %>
<% if @topic.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@topic.errors.count, "error") %> prohibited this topic from being saved:</h2>
<h2><%=t 'activerecord.errors.template.header', :count => @topic.errors.size, :model => @topic.class.model_name.human %></h2>
<h4><%=t 'activerecord.errors.template.body', :count => @topic.errors.size %></h4>
<ul>
<% @topic.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
......@@ -11,17 +11,9 @@
</div>
<% end %>
<div class="field">
<%= f.label :user %><br />
<%= f.text_field :user %>
</div>
<div class="field">
<%= f.label :type %><br />
<%= f.text_field :type %>
</div>
<div class="field">
<%= f.label :board %><br />
<%= f.text_field :board %>
<%= f.select :category_id, Board.all.collect{|board|[board.name, board.id]} %>
</div>
<div class="field">
<%= f.label :name %><br />
......@@ -31,18 +23,10 @@
<%= f.label :displayorder %><br />
<%= f.text_field :displayorder %>
</div>
<div class="field">
<%= f.label :views %><br />
<%= f.text_field :views %>
</div>
<div class="field">
<%= f.label :readperm %><br />
<%= f.text_field :readperm %>
</div>
<div class="field">
<%= f.label :notice %><br />
<%= f.check_box :notice %>
</div>
<div class="field">
<%= f.label :reverse %><br />
<%= f.check_box :reverse %>
......@@ -51,6 +35,7 @@
<%= f.label :private %><br />
<%= f.check_box :private %>
</div>
<%= f.hidden_field :category_type %>
<div class="actions">
<%= f.submit %>
</div>
......
<%= form_tag :controller => :topics do %>
<p>
<%= @board.id %>
<%=t 'topic.title' %><%= text_field_tag "topic[name]" %>
</p>
<p>
<%= render 'topics/editor' %>
</p>
<%= hidden_field_tag "topic[category_id]", @board.id %>
<%= hidden_field_tag "topic[category_type]", :board %>
<%= submit_tag t("topic.submit") %>
<% end %>
\ No newline at end of file
<h1>New topic</h1>
<%= render 'form' %>
<%= link_to 'Back', topics_path %>
......@@ -200,7 +200,8 @@ zh-CN:
errors:
<<: *errors
models:
user: 用户
user: "用户"
topic: "主题"
attributes:
pm:
to_user: "收件人"
......@@ -259,8 +260,12 @@ zh-CN:
top_traps: "热门陷阱"
board:
index: "论坛"
topic:
name: "标题"
posts: "帖子"
post:
attachments: "附件"
content: "正文"
mycard:
download: "立即下载"
battlenet: "YGO战网"
......
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