ruby可以这样写

@articles = Article.order("created_at DESC").where(:group_id => params[:group_id]).limit(5)

@count = Article.where(:group_id => params[:group_id]).count

@group = Group.where(:school => params[:school], :name => params[:name], :is_audited => true).first

redirect_to root_path,:notice => "There is no group in #{params[:school]}." if @groups.size == 0

你可能感兴趣的:(Ruby)