undefined method `stringify_keys!' ruby on rails

后端 未结 1 1311
执念已碎
执念已碎 2020-12-03 10:22

I have this code:

def addcar
  @car = Car.new(params[:car])
  render :action => \'list\'
end

<% @allcars.each do |cell| %>
  

<%= l

1条回答
  •  生来不讨喜
    2020-12-03 11:00

    in the addcar method, you try to create a new object (create method) while transfering just a string to it (params[:car] which apparently is set to "Honda").

    create expects to get an attributes hash and to stringify it's keys for the column names.

    If you have a column named name in your cars table then try this:

    @car = Car.new(:name => params[:car])
    

    0 讨论(0)
提交回复
热议问题