我正在使用 Yard 生成文档,但我找不到任何关于 ruby on rails 项目的示例文档。我发现只有简短的入门教程,以及rubydoc.info上的一些 github 项目,但它们根本没有记录。请有人告诉我如何正确记录控制器(带有动作),模型,rails项目的路线
例如我有这样的控制器:
class ArticlesController < ApplicationController
before_filter :authenticate_user!, except: [:show]
before_filter :restrict_user, only: [:edit, :update]
def index
@articles = current_user.articles.sort_by_rating.
paginate(:page => params[:page],
per_page: 5)
end
def new
@user = User.find(params[:user_id])
@article = @user.articles.build
end
def create
@user = User.find(params[:user_id])
@article = @user.articles.build(params[:article])
if @article.save
redirect_to @article, notice: 'Article was successfully created.'
else
render action: "new"
end
end
end
和一个用户模型:
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable :recoverable
devise :database_authenticatable, :registerable,
:rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :name, :email, :password, :password_confirmation, :remember_me
# attr_accessible :title, :body
validates_presence_of :name
validates_uniqueness_of :name, :email, :case_sensitive => false
has_many :articles, dependent: :destroy
letsrate_rater
end