您正在查看 "Rorcms" 分类下的文章 2010/08/06 16:07 2010/08/06 16:06 2010/08/06 16:05 当创建文章的时候,给对应的频道contents_count加1
由于没有删除文章的,所以不考虑删除.
- def create
- @article = Article.new(params[:article])
- respond_to do |format|
- if @article.save
- @article.channel.increment!(:contents_count) #这条新增的
- #Channel.find(@arti
|
2010/08/06 16:04 安装 awesome_nested_set: 无限级分类树形插件
- script/plugin install git://github.com/collectiveidea/awesome_nested_set.git
复制代码
channel model调用
- class Category < ActiveRecord::Base
- acts_as_nested_set
- ....
- end
|
2010/08/06 16:03 在项目里,安装搜索插件
- script/plugin install git://github.com/binarylogic/searchlogic.git
复制代码
controller部分
- def index
- @search = Article.search(params[:search])
- @articles = @search.paginate(:include
|
2010/08/06 16:02
当访问show的时候字段hits加1,并保存
- def show
- @article = Article.find(params[:id])
- @article.increment!(:hits) #增加这句
| |
2010/08/06 16:02 首先去下载用plugin来实现此功能,有上传文件、拼写检查的功能等的fckeditor,下载最新版本即可.
- http://rubyforge.org/frs/?group_id=2038
复制代码
下载完,解压缩后起名字fckeditor然后放到项目的这个目录下
然后,安装
|
2010/08/06 15:58 分页插件will_paginate安装
- ./script/plugin install git://github.com/mislav/will_paginate.git
复制代码
然后controller/articles_controller.rb里的
- def index
- @articles = Article.paginate(:include => [:channel],:page=>params[:page] || 1, :per_page=>10,:order=>"id desc")
|
2010/08/06 15:58 首先在项目录里运行,会在vendor里生成i18n_generators
- ./script/plugin install git://github.com/amatsuda/i18n_generators.git
复制代码
然后修改conif/environment.rb,这样是调用 locales/zh-CN.yml文件
- config.i18n.default_locale = 'zh-CN'
|
2010/08/06 15:57 在MODEL增加验证,设置必填字段
- validates_presence_of :title,:channel_id,:content
复制代码
|
2010/08/06 15:56
下载一个插件: annotate
Model 插件:vendor/plugins/annotate_models
说明:给把字段描述注视加到model里,
使用方法:rake annotate
会在每一个model下生成对应的,这里可以在model方便看到有哪些字段
# == Schema Information
# Schema v | |
2010/08/06 15:54
文章模块 Articles
分类模块 Categories
频道模块 Channels
评论模板 Comments
用户模板 Users
附件模块 Attachments
站点模板 Views
站点样式 Styles
网站缩写 Partials |
Articles文章模块字段 |
| | |