DiscussDemo代码
This commit is contained in:
parent
8ad4dba8c2
commit
5c4a62dcc4
|
@ -0,0 +1,27 @@
|
|||
class DiscussDemoController < ApplicationController
|
||||
def index
|
||||
@discuss_demo_list = DiscussDemo.order("created_at desc").page(params[:page] || 1).per(10)
|
||||
end
|
||||
|
||||
def new
|
||||
|
||||
end
|
||||
|
||||
def create
|
||||
discuss_demo = DiscussDemo.new(:title => params[:discuss_demo][:title],:body =>params[:discuss_demo][:body])
|
||||
discuss_demo.save!
|
||||
redirect_to :controller=>'discuss_demo',:action => 'show',:id => discuss_demo.id
|
||||
end
|
||||
|
||||
def update
|
||||
|
||||
end
|
||||
|
||||
def delete
|
||||
|
||||
end
|
||||
|
||||
def show
|
||||
@discuss_demo = DiscussDemo.find(params[:id])
|
||||
end
|
||||
end
|
|
@ -0,0 +1,2 @@
|
|||
module DiscussDemoHelper
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
class DiscussDemo < ActiveRecord::Base
|
||||
attr_accessible :title, :body
|
||||
validates_presence_of :title, :body
|
||||
end
|
|
@ -0,0 +1,21 @@
|
|||
<h1 style="">文章列表</h1>
|
||||
<div>
|
||||
<table border="1px solid !important" >
|
||||
<% @discuss_demo_list.each do |e| %>
|
||||
|
||||
<tr align="left" height="20">
|
||||
<td width="30%" ><%= truncate(e.title,:length => 50) %></td>
|
||||
<td align="center" width="60%">
|
||||
<%= textAreailizable truncate(e.body,:length => 500) %>
|
||||
</td>
|
||||
<td style=" margin-right: 1" width="10%">
|
||||
<%= link_to '查看文章',{:controller => 'discuss_demo',:action => 'show',:id=>e.id} %>
|
||||
</td>
|
||||
</tr>
|
||||
<tr height="20"></tr>
|
||||
<tr height="20"></tr>
|
||||
<% end %>
|
||||
</table>
|
||||
<% paginate @discuss_demo_list %>
|
||||
<%= link_to '新建文章',new_discuss_demo_path %>
|
||||
</div>
|
|
@ -0,0 +1,7 @@
|
|||
<%= javascript_include_tag src='/assets/kindeditor/kindeditor' %>
|
||||
<h1>新建文章</h1>
|
||||
<%= form_for :discuss_demo do |f| %>
|
||||
<%= f.text_field :title %>
|
||||
<%= f.kindeditor :body %>
|
||||
<%= f.submit :value=> '提交' %>
|
||||
<% end %>
|
|
@ -0,0 +1,2 @@
|
|||
<h1><%= @discuss_demo.title %></h1>
|
||||
<%= textAreailizable @discuss_demo.body %>
|
Loading…
Reference in New Issue