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

临时提交

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