What is the equivalent of script/destroy scaffold User in Rails 3? - ruby-on-rails

When I was using Rails 2, I did script/generate scaffold User to create the user model. Now I need to remove it, and I'm using Rails 3. I tried rails destroy scaffold User and rails destroy User, but these just created new rails projects named destroy. How do I do it? Thanks for reading.

Are you sure you are not running an older rails version at the time? Maybe forgot to switch to your Rails3 gemset with RVM?
It works fine here and this is the rails help output:
In addition to those, there are:
application Generate the Rails application code
destroy Undo code generated with "generate"

Related

Could not create scaffold in rails 4.1.10

The options for rails is being displayed
I am new to rails. I went through a tutorial and it generated a scaffold. I tried the same as shown in the picture but could not generate it.
In the image that you posted, it seems that you didn't create your project first. Do this steps:
rails new AppName
After the app auto-bundled, go to your app directory and,
rails g scaffold Todo title:string notes:text
You can follow the following tutorial from Ruby on Rails Guides

Why might columns added with migrations not show up in rails admin?

I added some columns to a table using rails and rake, but they do not show up in rails admin. What might be a reason for this? I am successfully registering new objects using them...
Turns out I just needed to restart the rails server.

Ruby On rails project without tests

I know it is not recommended but is there a way to generate/modify an existing project so it doesn't create test files when using generators such as rails generate controller NAME?
ruby script/generate controller Account --no-test-framework
Check out the API.

Ruby Error: "No such file or directory -- script/generate (LoadError)"

I know that this error has been discussed elsewhere on the web, and this may seem like a stupid question, but I've got a very strange situation on my hands here.
I'm running on Snow Leopard, with fully updated Ruby and Rails gems. I created a new Rails project using ruby new testing, then navigated into that folder using cd ~/testing, and tried to create a basic scaffolding using ruby script/generate scaffold newtest name:string, and I got this error back:
ruby: No such file or directory -- script/generate (LoadError)
I have searched Google thoroughly and tried to implement every solution that I could, but nothing has been working. I don't understand why I have this error or how to fix it.
If you are on rails 3 then the command is:
rails generate scaffold newtest name:string
Or the slightly shorter:
rails g scaffold newtest name:string
Notice rails not ruby.
If you're on Rails 3, you need to use the rails command instead, which now does much of the scripting.
(This is according to another StackOverflow question.)
If you're using the latest version of rails then you no longer use script/generate.
In Rails 3 try using something like this instead:
cd ~/testing
rails generate scaffold Post name:string title:string content:text
You can find more info on the difference between rails 2 and rails 3 here if you like:
http://www.viget.com/extend/rails-3-generators-scaffolding/

Add a new feature to existing rails project

I have recently downloaded a new project(open source),i found certain features missing like blog,forum ,chat etc.. ..so I like to add those features to the project .My problem if run rails forum it will create a new rails project but i want to add to the existing project. I have found business logic. . . .
I had created models
ruby script/generate model forum
ruby script/generate model topic
ruby script/generate model post
rake db:migrate
ruby script/generate migration add_foreign_to_topics forum_id:integer
ruby script/generate migration add_foreign_to_post topic_id:integer
rake db:migrate
Then i ran
ruby script/generate controller forum
it was asking should i overwrite or not,so i am stuck up here,i need to create a controller and view for this feature.I am following this tutorial http://net.tutsplus.com/tutorials/other/building-a-forum-from-scratch-with-ruby-on-rails/ and i have already user table etc..
As far as i can read, you are not following the tutorial, as it does a scaffold which generates the controller and models at the same time.
Either you do something like
ruby script/generate scaffold Forum title:string contents:text
and it generates the model, controller, routes and views for you. In the tutorial they use nifty_scaffold and i think it mostly improves the view.
If you create the models seperately, you need to do something like
ruby script/generate controller Forum index show create edit update new destroy
and then you will have to fill in all those actions yourself. You will also have to set your routes correctly. That is not bad and not at all difficult. But when you are starting, using the scaffold is much easier.

Resources