-1

I have a controller that works without a table in the database. At the moment, there is an action index that performs a request to the api from which it performs the action. Route looks like /car_collector.

And my question is how to create a route /car_collector/:id/edit without creating table in database.

Just creating a route get '/car_collector/:id/edit', to: 'car_collector#edit', as: 'edit_doc_collector', param: :id an error is generated ActiveRecord::StatementInvalid in Admin::CarCollectorController#edit

  • `ActiveRecord::StatementInvalid` -- is it full error message? May be you have notexecuted migrations for example? – mechnicov Aug 19 '22 at 12:56
  • @mechnicov Migration is not needed here, since we do not have a table for this controller Mysql2::Error: Table 'cars_core_dev.car_collectors' doesn't exist: SHOW FULL FIELDS FROM `car_collectors` – Danil Kravchenko Aug 19 '22 at 13:05
  • Rails raises such exception if app have not-executed migrations -- it is one of the reason. Does this error appear only on edit path? If yes, how this action looks? Do you have some before filters in this controller? – mechnicov Aug 19 '22 at 13:14
  • @mechnicov All migrations are done, there are no filters before. I myself do not understand why this happens. I found one case on the Internet, and everything is ok there, I don’t know why it doesn’t work for me. – Danil Kravchenko Aug 19 '22 at 13:29

1 Answers1

0
resources :car_collector, only: :edit

That's it, you don't need do sometning extra

After that just go to /car_collector/1/edit, /car_collector/2/edit etc.

Default param will be as params[:id]

mechnicov
  • 12,025
  • 4
  • 33
  • 56