Command that creates the actual model file that holds all the methods unique to the model and the business rules, a unit test file for performing test-driven development,fixtures to use with the unit tests, and a Rails migration
Questions tagged [rails-generate]
56 questions
2
votes
1 answer
How to get documentation from Rails generators about type modifiers
In the documentation for Active Record Migrations in Rails 4.2.x, the section 2.3 Passing Modifiers says:
Some commonly used type modifiers can be passed directly on the
command line. They are enclosed by curly braces and follow the field
…

Andrew Grimm
- 78,473
- 57
- 200
- 338
2
votes
4 answers
Rails 4 engine with nested namespace
I could not find a way to generate engines with nested namespaces under rails. Every time I do that, I basically have to edit and move around the generated files by hand.
Is there really no support for nested namespaces in rails? Seems unlikely.
At…

Ákos Vandra-Meyer
- 1,890
- 1
- 23
- 40
1
vote
1 answer
Rails generator `inject_into_file` at the end of file
Is there a way to append something to file using generator's inject_into_file? It has to get a :before or :after parameter but what should I pass to just append something?

pmichna
- 4,800
- 13
- 53
- 90
1
vote
0 answers
Where list of generators configure keys?
Where list or how to fetch list of generators keys (assets,template_engine) for disabling like this:
config.generators do |g|
g.assets false
g.template_engine false
end
When execute rails generate it show generators list. It is possible to…

fl-web
- 462
- 5
- 16
1
vote
1 answer
How to change the column type from string to varchar using script/generate in a rails app?
Trying to migrate a sqlite3 db for a rails app to mysql db. The column named "content" was a string type in sqlite3. I want to change it to varchar (or perhaps text) in mysql. I am not sure if there is a way to do this by using "ruby…

rst
- 31
- 2
1
vote
1 answer
How to use rails generators without active record
I am building a rails app without a database.
In Disable ActiveRecord for Rails 4 I learned how to configure the app so that the absence of the database related gems does not interfere with running it. The problem is that I still want to create…

gaudi_br
- 183
- 2
- 12
1
vote
1 answer
How to regenerate config/application.rb in Rails 4.2?
Does Rails 4.2 provide a single command that regenerates config/application.rb in an existing application?
The reason I ask is imagine a Rails app is rails new-ed without the --skip-test-unit option.
Then at a much later date, this app is switched…

Eliot Sykes
- 9,616
- 6
- 50
- 64
1
vote
1 answer
Rails g migration goes new line and does nothing
$ rails generate migration add_password_digest_to_users password_digest:string
Have to add password_digest to user but rails generate comand doesn't work. It just pretending to work but seems like it will lasts forever. No errors or backtrace were…

tomcat1911
- 81
- 6
1
vote
0 answers
Rails: Best way to stub out a model with a string ID?
Say I want to stub out a Product model which will have a product_id field of type string.
Do I add product_id in addition to the default id field that Rails creates?1
rails g model product product_id:string:uniq
Or make product_id the primary…

Dennis
- 56,821
- 26
- 143
- 139
1
vote
3 answers
Rails 4 uninitialized constant Admin::Category
I have generated Admin namespaced Controllers for all my default models as follows:
rails g scaffold_controller admin/categories name:string slug:string description:string icon_xlarge:string icon_large:string icon_medium:string icon_small:string…

Harsha M V
- 54,075
- 125
- 354
- 529
1
vote
1 answer
Rails Devise generate error
I'm fairly new to rails and I'm trying to set up devise and omniauth to allow users to login to my website with the Facebook API. I'm using this tutorial…

Slicekick
- 2,119
- 5
- 24
- 35
1
vote
1 answer
Ruby on Rails generators with new gemified plugin?
I'm attempting to create a new Rails 3 plugin gem which wraps around devise/devise_ldap_authenticatable for reusable drop in internal LDAP support.
I create the new plugin gem with:
rails plugin new
I then add the…

azurewraith
- 378
- 1
- 3
- 13
0
votes
2 answers
Why doesn't the Rails migration generator respect the fields I ask for?
I use the command like this:
administrator@ubuntu:~/demo$ rails generate migration Testabc test123:string
and the terminal respond:
invoke active_record
create db/migrate/20120204124219_testabc.rb
But in the file`s content is:
class Testabc <…

Rinko Kobayakawa
- 49
- 1
- 6
0
votes
1 answer
What's the proper way to set up date fields for a database?
So I have 3 fields in my HTML, lunchMonth, lunchDay and lunchYear
lunchMonth and lunchDay are Select tags with option tags for months and days remaining in the year. lunchYear is set to 2011.
I've set up a form but I need to generate a scaffold to…

Zack Shapiro
- 6,648
- 17
- 83
- 151
0
votes
1 answer
How do I fix the wrongly generated Scaffold?
For convenience let's say we run the following:
bin/rails generate scaffold Candidate::Test
The generating function then proceeds to generate all the major components on the corresponding module names. Everything should work fine if I do a rails…

benj-by
- 5
- 2