Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails RubyonRails,我尝试使用应用程序创建表单,但当我进入显示页面时,一切都是空的_Ruby On Rails_Ruby_Show_React Rails - Fatal编程技术网

Ruby on rails RubyonRails,我尝试使用应用程序创建表单,但当我进入显示页面时,一切都是空的

Ruby on rails RubyonRails,我尝试使用应用程序创建表单,但当我进入显示页面时,一切都是空的,ruby-on-rails,ruby,show,react-rails,Ruby On Rails,Ruby,Show,React Rails,我是RubyonRails新手,在提交表单时遇到了一个问题。当我准备创建表单(如第一张图所示)时,一切都很好,但当我到达显示路径时,我没有显示我输入表单的内容(如第二张图所示)。有人能回避我的错误吗? 在my todos_controller.rb中: class TodosController < ApplicationController def index @todos= Todo.all end def new end def show @todo = To

我是RubyonRails新手,在提交表单时遇到了一个问题。当我准备创建表单(如第一张图所示)时,一切都很好,但当我到达显示路径时,我没有显示我输入表单的内容(如第二张图所示)。有人能回避我的错误吗?

在my todos_controller.rb中:

class TodosController < ApplicationController
def index
    @todos= Todo.all
end

def new
end

def show
    @todo = Todo.find(params[:id])
end

def create
    @todo= Todo.new(todo_params)

    @todo.save
    redirect_to @todo
end

private
    def todo_params
        params.require(:todo).permit(:task, :description)
    end
end
在表单页面(todo#new)上,需要为要保存到数据库中的那些属性(:task,:description)设置一个对象

<p>
    <strong>Task:</strong>
    <%= @todo.task %>
    </p>

<p>
     <strong>Description:</strong>
     <%= @todo.description %>
     </p>
Rails.application.routes.draw do
get 'welcome/index'

resources :todos

root 'welcome#index'
end