Questions tagged [rails-generate]

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

56 questions
516
votes
17 answers

How to reverse a 'rails generate'

I want to delete all the files it created and roll back any changes made, but not necessarily to the database, but more to the config files. I'd like to automatically delete all the resource mappings for the model/controller deleted in the routes.rb…
marcamillion
  • 32,933
  • 55
  • 189
  • 380
33
votes
3 answers

How do I generate a controller spec using rspec?

I'm integrating devise_invitable into my application and I had to write a custom controller - InvitationsController - to override a few methods in the gem. Now, I want to write tests to cover what I've done but I can't figure out how to generate a…
spinlock
  • 3,737
  • 4
  • 35
  • 46
19
votes
2 answers

Missing script/generate in Rails 3

I just installed Rails 3 and created my first app. The install of Rails3 + ruby 1.9 went very smoothly but I am missing the generate script in script/generate. I have created a new app from scratch with no options to verify. Any idea why this is…
Tony
  • 18,776
  • 31
  • 129
  • 193
11
votes
4 answers

Rails - using `rails generate model` to specify non-nullable field type

According to the rails documentation http://guides.rubyonrails.org/migrations.html 2.3 Supported Type Modifiers says it should be possible to modify fields to allow or disallow NULL in the column, and that it's possible to do this on the…
Alan
  • 297
  • 3
  • 12
6
votes
2 answers

automatically open Rails generate migration file in editor

Is it possible to configure Rails so that after running rails g migration name_of_migration, it automatically opens that file in TextMate?
ma11hew28
  • 121,420
  • 116
  • 450
  • 651
4
votes
3 answers

rails script/generate skip unnecessary files by default

Script/generate became very annoying since I started using rspec etc. I dont need unit test files and fixtures anymore, but script/generate makes them anyway. Is it possible to set --skip-fixtures and --skip-test to be default system-wide (or at…
Mantas
  • 5,691
  • 6
  • 27
  • 24
4
votes
5 answers

Entering Rails commands in Terminal, Help is returned

When I enter: $ rails server I get this returned for and rails commands entered: Usage: rails new APP_PATH [options] Options: [--edge] # Setup the application with Gemfile pointing to Rails repository [--dev] …
user1079454
4
votes
1 answer

Rails 4 custom generator, revoke/invoke

Given a simple custom generator: # lib/generators/custom_model/custom_model_generator.rb class CustomModelGenerator < Rails::Generators::NamedBase def rails_generate_model generate 'model', "#{file_name} #{args.join(' ')}" end end Which…
4
votes
1 answer

How to automaticly generate password if not provided with authlogic

I'm new on both this site and ruby on rails! I have a common installation of authlogic and want password to be generated automaticly for user registration if user did not set the password. What is the best way to do it?
vooD
  • 2,881
  • 2
  • 25
  • 34
3
votes
1 answer

Rails - Could not find i18n-0.9.5 in any of the sources

I'm working on a Ruby website using MySQL and I was working on internationalization using Globalize. However, when I run rails g migration create_translation_for_articles The terminal displays the following: Could not find i18n-0.9.5 in any of the…
TamerB
  • 1,401
  • 1
  • 12
  • 27
3
votes
2 answers

Does rails scaffold command support generate belongs_to or many to many model middle table migration info?

Product,Category is two model on rails3 the relation between them are follow: product has_and_belongs_to_many categories category has_and_belongs_to_many products i can use scaffold generate migration for this two modle use rails g scaffold product…
mlzboy
  • 14,343
  • 23
  • 76
  • 97
3
votes
1 answer

How to namespace generators that don't live in a Gem

I'm confused. A gem that I used, called railsy_backbone, provides sweet namespaced generators. From the command-line I can invoke them thus, $ rails g backbone:model widget Now, it is time for me to make sweet generators, but I'm having trouble with…
Ziggy
  • 21,845
  • 28
  • 75
  • 104
3
votes
2 answers

Adding a hook to script/generate migration

I do my Rails dev from xterm and in vim. I'm getting sick of running script/generate migration do_whatever, then trawling through db/migrate trying to tab-complete to 20091015235018_do_whatever when there's 5 other migrations with similar…
nfm
  • 19,689
  • 15
  • 60
  • 90
3
votes
1 answer

Rails generate controller boilerplate for existing resource?

I used generate scaffold to setup the basic RESTful actions however I want to extend the actions to include something like 'purchase'. Is there a way to use the command line to generate the boilerplate (stub functions in controller file and updated…
bias
  • 1,467
  • 3
  • 19
  • 39
2
votes
2 answers

How to turn off generators for RSpec 2 in Rails 3?

I installed the current RSpec 2 Beta under Rails 3 RC as mentioned on the GitHub page (and several blogs). Everything works fine, but I am not able to turn off specific generators like advised on some blogs. Here is what I do in…
medihack
  • 16,045
  • 21
  • 90
  • 134
1
2 3 4