Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3 generate scaffold for specific actions only

My setup: Rails 3.0.9, Ruby 1.9.2

I wish to generate a scaffold only for the create action, what's the syntax for that? I'm guessing it's something I append to

rails g scaffold Project name:string ...
like image 777
Bob Avatar asked Jul 22 '11 18:07

Bob


People also ask

What does rails generate scaffold do?

Rails scaffolding is a quick way to generate some of the major pieces of an application. If you want to create the models, views, and controllers for a new resource in a single operation, scaffolding is the tool for the job.

What is the difference between static and dynamic scaffolding?

Static Scaffolding needs user insertion commands to generate data fields, whereas Dynamic Scaffolding generates the entire content at run time.

What is generator in Ruby on rails?

Ruby provides a script called Generator. This script can be used to generate many useful items in Rails.


1 Answers

Rails scaffolding is a very basic tool, it's not meant to be relied on, once you get a handle on the way rails works. However, you can use Ryan Bates' nifty-generator gem to generate scaffolds with greater control. Example:

rails g nifty:scaffold post name:string index new edit

Learn more here. https://github.com/ryanb/nifty-generators

like image 72
biodegabriel Avatar answered Oct 19 '22 23:10

biodegabriel