Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scaffold For specific actions?

How can I generate a scaffold for only specific action?

rails g scaffold user name create destroy (but its not working as expected, it create all 7 standard actions)

I only want to generate through scaffold command.

like image 648
Saumya Mehta Avatar asked Nov 19 '25 20:11

Saumya Mehta


1 Answers

After looking into the docs and reading rails g scaffold --help and rails g scaffold_controller --help I come to the conclusion that what you want is not possible.

It makes some sense, since in Rails terms a scaffold controller is a RESTful controller, which implies that it creates those 7 standard actions so you can say resources :users in your routing file.

I think you just have to manually remove the unwanted actions, views and routing behaviour. Or perhaps better: just create everything from scratch or from a regular rails g controller index show-like command, and then fill in the blanks using copy/paste from some other scaffolded resource.

like image 144
zwippie Avatar answered Nov 21 '25 09:11

zwippie