0
votes

-My routes.rb

-resources :manufacturers do - resources :vehicle_data -end

-In controller

  • def create
  • @manufacturer = Manufacturer.find(params[:manufacturer_id])
  • @vehicle_data = @manufacturer.vehicle_data.create(params[:vehicle_data])
  • @vehicle_data.save -end

-In Views

-<%= form_for([@manufacturer, @manufacturer.vehicle_data.build]) do |f| %>

-When trying to create new record

-NameError in Vehicle_data#index

-Showing C:/Users.../app/views/vehicle_data/index.html.erb where line #12 raised:

-uninitialized constant Manufacturer::VehicleDatum -Extracted source (around line #12):

-9: -10: -11: -12: <%= form_for([@manufacturer, @manufacturer.vehicle_data.build]) do |f| %> -13:
-14:

How do I make this form work??? Why the model name is changed from VehicleData to VehicleDatum

1

1 Answers

3
votes

Rails expects models to be the singular form of the resource you defined, and the singular of data is datum, so it expects your class to be a VehicleDatum. If this isn't the pluralization that you want to use, see How do I override rails naming conventions?