我可以在 Rails 中禁用“Edit”和“Destory”吗?例如,如果我想为所有人禁用“Edit”,我在 test_controller.rb 中做什么显示?还是别的什么?我是 Rails 的新手,提前致谢!
class BooksController < ApplicationController
before_action :set_book, only: [:show, :edit, :update,:destroy ]
# GET /books
# GET /books.json
def index
@books = Book.all
end
# GET /books/1
# GET /books/1.json
def show
end
# GET /books/new
def new
@book = Book.new
end
# GET /books/1/edit
def edit
end
# POST /books
# POST /books.json
def create
@book = Book.new(book_params)
respond_to do |format|
if @book.save
format.html { redirect_to @book, notice: 'Book was successfully created.' } …Run Code Online (Sandbox Code Playgroud)