我使用nested_scaffold生成嵌套模型。我想删除模型Course
。
我希望所有与课程相关的文件都应删除。但需要ClassRoom
模型。关系也应该从ClassRoom
删除,并且还应删除 route
文件。
我使用了以下命令来生成nested_scaffold:
rails generate nested_scaffold ClassRoom/Course name:string
答案 0 :(得分:3)
撤消嵌套脚手架
rails destroy nested_scaffold ClassRoom/Course
答案 1 :(得分:2)
您可以使用scaffold
rails destroy scaffold class_room/course name:string
结果:
invoke active_record
remove db/migrate/20151006093322_create_class_room_courses.rb
remove app/models/class_room/course.rb
invoke test_unit
remove test/models/class_room/course_test.rb
remove test/fixtures/class_room/courses.yml
invoke resource_route
route namespace :class_room do
resources :courses
end
invoke scaffold_controller
remove app/controllers/class_room/courses_controller.rb
invoke erb
remove app/views/class_room/courses
remove app/views/class_room/courses/index.html.erb
remove app/views/class_room/courses/edit.html.erb
remove app/views/class_room/courses/show.html.erb
remove app/views/class_room/courses/new.html.erb
remove app/views/class_room/courses/_form.html.erb
invoke test_unit
remove test/controllers/class_room/courses_controller_test.rb
invoke helper
remove app/helpers/class_room/courses_helper.rb
invoke test_unit
invoke jbuilder
remove app/views/class_room/courses
remove app/views/class_room/courses/index.json.jbuilder
remove app/views/class_room/courses/show.json.jbuilder
invoke assets
invoke coffee
remove app/assets/javascripts/class_room/courses.coffee
invoke scss
remove app/assets/stylesheets/class_room/courses.scss
invoke scss
然后你可以迁移它。
rake db:migrate
我希望这对你有所帮助。