Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.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 4 错误:“参数丢失或值为空:学生”_Ruby On Rails 4 - Fatal编程技术网

Ruby on rails 4 错误:“参数丢失或值为空:学生”

Ruby on rails 4 错误:“参数丢失或值为空:学生”,ruby-on-rails-4,Ruby On Rails 4,我不熟悉rails。我无法理解错误是什么以及如何修复它。 错误为缺少参数或值为空:students 佣工表格` <%= form_for :students, :url=>{:action=>'create'} do |f| %> 请尝试以下代码: 学生控制员 看法 如果你检查参数,你会发现你的参数不是这个形式 {students: {'s_name': 'xyz', 'batch': 'cse'}} 这意味着之前由@puneet解释的答案是让CRUD这样做的

我不熟悉rails。我无法理解错误是什么以及如何修复它。 错误为缺少参数或值为空:students

佣工表格`

    <%= form_for :students, :url=>{:action=>'create'} do |f| %>
请尝试以下代码:

学生控制员 看法
如果你检查参数,你会发现你的参数不是这个形式

{students: {'s_name': 'xyz', 'batch': 'cse'}}
这意味着之前由@puneet解释的答案是让CRUD这样做的最好方法

def new
  @student = Student.new
end

def create
  @student = Student.new(student_params)
  @student.save
end

def student_params
  params.require(:students).permit(:s_name,:batch,:roll_no,:branch,:gender,:date_of_birth,:contact_no_1,:contact_no_2,:email,:spi_1,:spi_2,:spi_3,:spi_4,:spi_5,:spi_6,:spi_7,:cpi_7,:percent_10,:percent_12)
end
<% form_for @student do |f| %>
  ...
<% end %>
{students: {'s_name': 'xyz', 'batch': 'cse'}}