Ruby on rails 4 错误:“参数丢失或值为空:学生”
我不熟悉rails。我无法理解错误是什么以及如何修复它。 错误为缺少参数或值为空:students 佣工表格`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这样做的
<%= 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'}}