我這裏有https://pastebin.com/JfXr054y表單字段不保存到數據庫 - Ruby on Rails的
在routes.rb
形式我有
resources :landslides, only: [:new, :create, :index]
在landslides_controller.rb
我
def new
@landslide = Landslide.new(landslide_params)
@landslide.save
render plain: @landslide.inspect
end
和
def landslide_params
params.require(:landslide).permit(:total_id, :year_id, :start_date, :end_date, :day_number, :continent, :country, :location, :type, :admin_level, :new_lat, :new_long, :mapped, :spatial_area, :fatalities, :injuries, :notes, :sources)
end
爲什麼表格沒有保存到表格中?
檢查返回值保存,也許這是因爲你的模型的驗證。 – yoones