我试图让Rails中一个字计数器,文字是一种脚手架的名字,但我 @counter变量似乎并没有被赋予任何输出如何解决这个@counter没有给出输出 - Rails的
class TextsController < ApplicationController
before_action :set_text, only: [:show, :edit, :update, :destroy]
def index
@texts = Text.all
end
def new
@text = Text.new
end
def edit
end
def create
@text = Text.new(text_params)
@counter = @text.name.split.size
end
private
def set_text
@text = Text.find(params[:id])
end
def text_params
params.require(:text).permit(:name, :string)
end
端
VIEW
<p id="notice"><%= notice %></p>
<%= @text.name %>
<%= @counter %>
什么在'@ text.name'? –
应该算作课本的文本 –
我的意思是,当你在柜台里什么都没有时。它是什么? –