前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Rails 构建评论功能(4)

Rails 构建评论功能(4)

作者头像
franket
发布2021-10-20 10:02:38
3410
发布2021-10-20 10:02:38
举报
文章被收录于专栏:技术杂记

生成控制器

代码语言:javascript
复制
[root@h202 blog]# rails generate controller Comments
Running via Spring preloader in process 3855
      create  app/controllers/comments_controller.rb
      invoke  erb
      create    app/views/comments
      invoke  test_unit
      create    test/controllers/comments_controller_test.rb
      invoke  helper
      create    app/helpers/comments_helper.rb
      invoke    test_unit
      invoke  assets
      invoke    coffee
      create      app/assets/javascripts/comments.coffee
      invoke    scss
      create      app/assets/stylesheets/comments.scss
[root@h202 blog]# cat app/controllers/comments_controller.rb
class CommentsController < ApplicationController
end
[root@h202 blog]# cat app/views/comments
cat: app/views/comments: Is a directory
[root@h202 blog]# ll app/views/comments
total 0
[root@h202 blog]# cat test/controllers/comments_controller_test.rb
require 'test_helper'

class CommentsControllerTest < ActionController::TestCase
  # test "the truth" do
  #   assert true
  # end
end
[root@h202 blog]# cat app/helpers/comments_helper.rb
module CommentsHelper
end
[root@h202 blog]# cat app/assets/javascripts/comments.coffee
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
[root@h202 blog]# cat app/assets/stylesheets/comments.scss
// Place all the styles related to the Comments controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
[root@h202 blog]# 

File name

Comment

app/controllers/comments_controller.rb

Comments 控制器文件

app/views/comments

控制器的视图存放在这个文件夹里,目前是空的

test/controllers/comments_controller_test.rb

控制器测试文件

app/helpers/comments_helper.rb

视图帮助方法文件

app/assets/javascripts/comments.coffee

控制器的 CoffeeScript 文件

app/assets/stylesheets/comments.scss

控制器的样式表文件

本文系转载,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文系转载前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 生成控制器
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档