rails g scaffold articles isn't executed - ruby-on-rails

I am trying to generate a scaffold in an existing project but when I run the command rails g scaffold articles title:string date:string content:text image:string nothing happens...
$ rails g scaffold articles title:string date:string content:text image:string
I can't ever generate a controller???
rails g controller articles do nothing....
If I try in a new project it works what could be the problem please ?

I had to run stop spring and everything is back to normal !

Related

Is there any command for delete rails generated using scaffold files

Hi I want to delete all stuff related to rails generate scaffold at once.
You can use this command and enjoying......
rails destroy scaffold scaffoldname
scaffold name = The name of generated scaffold which you generate..
rails d scaffold yourscaffoldname
(In your terminal)

ruby:No such file or directory--script/generate(Load error)

I typed code"ruby script/generate model as name:string description:text price:decimal seller_id:integer email:string img_url:string"in"rail_apps".but the cmd shows the error like what the title shows.You can know more refering to the Chap2 of the book"[深入浅出.Ruby.on.Rails].OReilly.Head.First.Rails.Jan.A.learner's.companion.to.Ruby.on.Rails.2009"I am looking forward your help.Thankyou~
In Rails 3, you need to use rails generate ... instead of ./script/generate ... (or ruby script/generate ...).
Likewise, script/console is now rails console (or rails c for short) and script/server is rails server (or rails s for short).

rails script/generate scaffold problem

I'm new to rails and was trying out the scaffold command - the following scaffold runs and works when I view it via web brick
script/generate scaffold book title:string
the following fails - gives me a weird route error
script/generate scaffold application name:string
the following works
script/generate scaffold app name:string
can anyone shed some light on this? Is 'application' a reserved word?
All your controllers are subclasses of ApplicationController, created by Rails. you can't create another controller with this name.
Yes Application is a reserved word
You can see a complete list on the Wiki
http://wiki.rubyonrails.org/rails/pages/reservedwords
Just so you know, make sure not to do this:
script/generate book title:string
You need to have the word scaffold after generate, like this:
script/generate scaffold book title:string

Can generate scaffold put the controller in a namespace?

I want to generate the scaffold in a Rails app, generating the model as usual but having the controller inside the admin namespace. Is it possible?
The first time I've done it, I run
script/generate scaffold blog
and then refactored the controller, views, etc. My prefered solution at the moment is:
script/generate scaffold admin::blog
and then refactor the model, unit test and migration; it's less work.
If there's a better answer, I'll accept it.
You can do this for rails < 3:
script/generate scaffold Blog title:string
or
script/generate scaffold admin::blog title:string
For rails > 3:
rails g scaffold Blog title:string
or
rails g scaffold admin/blog title:string
This question is pretty widely asked on stackoverflow. And I also faced this problem and found no standard solution for that.
So, I created rails-admin-scaffold gem (for now it's Rails 4 only) which automates this process and wrote an article with more detailed explanation. Hope it would be helpful for someone.
For Rails 6:
assuming you have a model like:
rails g model Foo name:string
then you can do this with
rails g scaffold_controller Admin/Foo name:string --model-name="Foo"
(specifying the model name stops the controller from referring to the model Admin::Foo which would be the default)
NB: this isn't perfect; You'll have to fix up a bunch of path errors in your views and tests - but it gets you 80% of the way there.

Is there an option to generate scaffolding without generating migrations?

One of the things that bothers me in Rails is that scaffolding generates migrations that I don't always need.
Is there a way to generate the scaffold without the corresponding migration?
Use the --skip-migration parameter. For example:
rails generate scaffold post title:string body:text --skip-migration

Resources