I can't migrate new columns in my database via the terminal and RoR.
I only get the first step:
**$ rails g migration add_online_to_posts online:boolean**
Running via Spring preloader in process 13406
invoke active_record
create db/migrate/20170808141302_add_online_to_posts.rb
Afterwards nothing works:
**$ rails db:migrate**
rails aborted!
ActiveRecord::DuplicateMigrationVersionError:
Multiple migrations have the version number 20170725122210.
/home/projets/RoR_formation/vendor/bundle/gems/activerecord-5.1.2/lib/active_record/migration.rb:1257:in `validate'
/home/projets/RoR_formation/vendor/bundle/gems/activerecord-5.1.2/lib/active_record/migration.rb:1123:in `initialize'
/home/projets/RoR_formation/vendor/bundle/gems/activerecord-5.1.2/lib/active_record/migration.rb:1007:in `new'
/home/projets/RoR_formation/vendor/bundle/gems/activerecord-5.1.2/lib/active_record/migration.rb:1007:in `up'
/home/projets/RoR_formation/vendor/bundle/gems/activerecord-5.1.2/lib/active_record/migration.rb:985:in `migrate'
/home/projets/RoR_formation/vendor/bundle/gems/activerecord-5.1.2/lib/active_record/tasks/database_tasks.rb:171:in `migrate'
/home/projets/RoR_formation/vendor/bundle/gems/activerecord-5.1.2/lib/active_record/railties/databases.rake:58:in `block (2 levels) in <top (required)>'
/home/projets/RoR_formation/vendor/bundle/gems/railties-5.1.2/lib/rails/commands/rake/rake_command.rb:21:in `block in perform'
/home/projets/RoR_formation/vendor/bundle/gems/railties-5.1.2/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/home/projets/RoR_formation/vendor/bundle/gems/railties-5.1.2/lib/rails/command.rb:46:in `invoke'
/home/projets/RoR_formation/vendor/bundle/gems/railties-5.1.2/lib/rails/commands.rb:16:in `<top (required)>'
/home/projets/RoR_formation/bin/rails:9:in `require'
/home/projets/RoR_formation/bin/rails:9:in `<top (required)>'
/home/projets/RoR_formation/vendor/bundle/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
/home/projets/RoR_formation/vendor/bundle/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
/home/projets/RoR_formation/vendor/bundle/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
/home/projets/RoR_formation/vendor/bundle/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
/home/projets/RoR_formation/vendor/bundle/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
/home/projets/RoR_formation/vendor/bundle/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
/home/projets/RoR_formation/vendor/bundle/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
/home/projets/RoR_formation/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Tasks: TOP => db:migrate
I can handle columns via the IDE:
But when I do :
**$ Status Migration ID Migration Name**
up 20170725122210 Create posts table
up 20170726082500 Rename post title to intitule
up 20170728143925 Create categories
up 20170807110617 ********** NO FILE **********
down 20170808113533 Add slug to posts
You've already run a migration with the prefix 20170725122210 (and it looks like you may have also deleted it). For a quick fix, change your newest migration to 20170725122211 (or any other number that isn't in your schema migrations table). You may also want to run rails db:schema:dump and inspect the output of db/schema.rb for tables that are not present in your migrations.
Related
I recently added the gem Active Admin to my rails applicaction (using rails 5.2.6), I got it to work with the default admin and it's working as intended. But I'm unable to add new admins with AdminUser.create!(email: "admin#gmail.com", password: "password", password_confirmation: "password") as I get the rails aborted error and then Don't know how to build task 'AdminUser.create!(email: "admin#gmail.com", password: "password", password_confirmation: "password").
I already tried using rails db:migrate and running my seeds.
Also I am using the devise gem.
Full trace:
rails aborted!
Don't know how to build task 'AdminUser.create!(email: example#gmail.com, password: password, password_confirmation: password)' (See the list of available tasks with `rails --tasks`)
/var/lib/gems/2.7.0/gems/rake-13.0.6/lib/rake/task_manager.rb:59:in `[]'
/var/lib/gems/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:159:in `invoke_task'
/var/lib/gems/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/var/lib/gems/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'
/var/lib/gems/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
/var/lib/gems/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'
/var/lib/gems/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
/var/lib/gems/2.7.0/gems/railties-5.2.6/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
/var/lib/gems/2.7.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
/var/lib/gems/2.7.0/gems/railties-5.2.6/lib/rails/commands/rake/rake_command.rb:20:in `perform'
/var/lib/gems/2.7.0/gems/railties-5.2.6/lib/rails/command.rb:48:in `invoke'
/var/lib/gems/2.7.0/gems/railties-5.2.6/lib/rails/commands.rb:18:in `<main>'
/var/lib/gems/2.7.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/var/lib/gems/2.7.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/var/lib/gems/2.7.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/var/lib/gems/2.7.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/var/lib/gems/2.7.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/home/magus/Desktop/Proyecto ing software/grupo-56/bin/rails:9:in `<top (required)>'
/var/lib/gems/2.7.0/gems/spring-2.1.1/lib/spring/client/rails.rb:28:in `load'
/var/lib/gems/2.7.0/gems/spring-2.1.1/lib/spring/client/rails.rb:28:in `call'
/var/lib/gems/2.7.0/gems/spring-2.1.1/lib/spring/client/command.rb:7:in `call'
/var/lib/gems/2.7.0/gems/spring-2.1.1/lib/spring/client.rb:30:in `run'
/var/lib/gems/2.7.0/gems/spring-2.1.1/bin/spring:49:in `<top (required)>'
/var/lib/gems/2.7.0/gems/spring-2.1.1/lib/spring/binstub.rb:11:in `load'
/var/lib/gems/2.7.0/gems/spring-2.1.1/lib/spring/binstub.rb:11:in `<top (required)>'
/usr/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:72:in `require'
/usr/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:72:in `require'
/home/magus/Desktop/Proyecto ing software/grupo-56/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
As I said before, all the other ActiveAdmin functionalities are working as intended, it's just that I can't create new admins.
What am I doing wrong/could have forgotten to do?
Thanks in advance.
There are several ways to add that admin into the database:
rails console - Just open the console and execute AdminUser.create!(...).
seeds.rb - Open the db/seeds.rb file and paste AdminUser.create!(...). Then run rake db:seed. Note that running rake db:seed multiple times will create that admin multiple times - it's best you have some sort of validations or use AdminUser.find_or_create_by(...) instead.
rake task - create a rake file in lib/tasks, name is not important but it should end in .rake (ex: update.rake)
task :add_admin do
AdminUser.find_or_create_by(email: "admin#gmail.com", password: "password", password_confirmation: "password")
end
Run it with rake add_admin.
If you want that admin only for yourself, your local machine, use the console approach, otherwise pick the other two but make sure the rake tasks are idempotent.
I am running
$ rails generate migration Tablename
command in command prompt. Should I see the newly created table in db/migrate? I am new in rails.
I can see the following error:
rails generate migration TruncateUnusedTables
.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/spring-1.5.0/lib/spring/client/run.rb:98:in `gets': Interrupt
.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/spring-1.5.0/lib/spring/client/run.rb:98:in `verify_server_version'
.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/spring-1.5.0/lib/spring/client/run.rb:56:in `run'
.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/spring-1.5.0/lib/spring/client/run.rb:37:in `warm_run'
.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/spring-1.5.0/lib/spring/client/run.rb:26:in `call'
.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/spring-1.5.0/lib/spring/client/command.rb:7:in `call'
.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/spring-1.5.0/lib/spring/client/rails.rb:24:in `call'
.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/spring-1.5.0/lib/spring/client/command.rb:7:in `call'
.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/spring-1.5.0/lib/spring/client.rb:28:in `run'
.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/spring-1.5.0/bin/spring:49:in `<top (required)>'
.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/spring-1.5.0/lib/spring/binstub.rb:11:in `load'
.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/spring-1.5.0/lib/spring/binstub.rb:11:in `<top (required)>'
from .rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from .rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /bin/spring:13:in `<top (required)>'
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'
I am new in rails.
Welcome! We're here to help.
Should I see the newly created table in db/migrate?
Not with $ rails generate migration Tablename. You will need to configure your migration such that the table is created. This is a big topic, so head over to the guides to read up on generating migrations.
I'm working on teaching myself both SQL & Ruby on Rails, and just starting out. I'm following a tutorial and successfully created a new SQL database and user, as well as a project.
The next step was to run a schema dump (even though the database is empty at the moment) just to confirm that the project could talk to the new database. Unfortunately it is a no go. I can see the database listed in my config/database.yml, and it contains the proper references to both the user and the database, but for some reason the schema dump fails.
Below are my commands, followed by the error, followed by the command again with a trace. I really appreciate any help you can offer.
C:\Users\Danny\Documents\Sites\demo_project>rails db:schema:dump
rails aborted!
LoadError: cannot load such file -- mysql2/2.4/mysql2
C:/Users/Danny/Documents/Sites/demo_project/config/application.rb:7:in `<top (required)>'
C:/Users/Danny/Documents/Sites/demo_project/Rakefile:4:in `require_relative'
C:/Users/Danny/Documents/Sites/demo_project/Rakefile:4:in `<top (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
(See full trace by running task with --trace)
C:\Users\Danny\Documents\Sites\demo_project>rails db:schema:dump --trace
rails aborted!
LoadError: cannot load such file -- mysql2/2.4/mysql2
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/mysql2-0.4.10-x64-mingw32/lib/mysql2/mysql2.rb:2:in `require'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/mysql2-0.4.10-x64-mingw32/lib/mysql2/mysql2.rb:2:in `<top (required)>'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/mysql2-0.4.10-x64-mingw32/lib/mysql2.rb:31:in `require'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/mysql2-0.4.10-x64-mingw32/lib/mysql2.rb:31:in `<top (required)>'
C:/Ruby24-x64/lib/ruby/site_ruby/2.4.0/bundler/runtime.rb:81:in `require'
C:/Ruby24-x64/lib/ruby/site_ruby/2.4.0/bundler/runtime.rb:81:in `block (2 levels) in require'
C:/Ruby24-x64/lib/ruby/site_ruby/2.4.0/bundler/runtime.rb:76:in `each'
C:/Ruby24-x64/lib/ruby/site_ruby/2.4.0/bundler/runtime.rb:76:in `block in require'
C:/Ruby24-x64/lib/ruby/site_ruby/2.4.0/bundler/runtime.rb:65:in `each'
C:/Ruby24-x64/lib/ruby/site_ruby/2.4.0/bundler/runtime.rb:65:in `require'
C:/Ruby24-x64/lib/ruby/site_ruby/2.4.0/bundler.rb:114:in `require'
C:/Users/Danny/Documents/Sites/demo_project/config/application.rb:7:in `<top (required)>'
C:/Users/Danny/Documents/Sites/demo_project/Rakefile:4:in `require_relative'
C:/Users/Danny/Documents/Sites/demo_project/Rakefile:4:in `<top (required)>'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.1/lib/rake/rake_module.rb:29:in `load'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.1/lib/rake/rake_module.rb:29:in `load_rakefile'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.1/lib/rake/application.rb:703:in `raw_load_rakefile'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.1/lib/rake/application.rb:104:in `block in load_rakefile'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.1/lib/rake/application.rb:186:in `standard_exception_handling'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.1/lib/rake/application.rb:103:in `load_rakefile'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-5.0.7/lib/rails/commands/rake_proxy.rb:13:in `block in run_rake_task'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.1/lib/rake/application.rb:186:in `standard_exception_handling'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-5.0.7/lib/rails/commands/rake_proxy.rb:11:in `run_rake_task'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-5.0.7/lib/rails/commands/commands_tasks.rb:51:in `run_command!'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-5.0.7/lib/rails/commands.rb:18:in `<top (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
In the below mentioned command you need compile yourself
C:\Users\xxxx\xxxx>gem install mysql2 --platform=ruby -- '--with-mysql-lib="I:\mysql-5.7.19-winx64\lib" --with-mysql-include="I:\mysql-5.7.19-winx64\include"'
If you still got the error then you might need to downgrade to 2.3 for mysql support.
For the mysql compatibility for rails on windows..please find below the github link:
https://github.com/brianmario/mysql2/issues/861
I’m using Rails 5 and PostGres 9.5 . I have a model with the following field …
title | character varying |
I would like to either create or update a model in my db/seeds file based on its title, which is a unique constraint. So I tried
scenario = Scenario.find_or_initialize_by_title(s.title)
scenario.update_attributes(Hash[*#record.attributes.except('created_at','updated_at','id').map { |a| [a.first, nil] }.flatten])
but I got the below error. What’s the correct way to create or update my model and also exclude the listed attributes?
localhost:sims nataliab$ rake db:seed
rake aborted!
NoMethodError: undefined method `find_or_initialize_by_title' for #<Class:0x007fb22d28f820>
Did you mean? find_or_initialize_by
/Users/nataliab/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.0.1/lib/active_record/dynamic_matchers.rb:21:in `method_missing'
/Users/nataliab/Documents/workspace/sims/db/seed/scenarios.rb:165:in `block in <top (required)>'
/Users/nataliab/Documents/workspace/sims/db/seed/scenarios.rb:164:in `each'
/Users/nataliab/Documents/workspace/sims/db/seed/scenarios.rb:164:in `<top (required)>'
/Users/nataliab/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
/Users/nataliab/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `block in require'
/Users/nataliab/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
/Users/nataliab/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
/Users/nataliab/Documents/workspace/sims/db/seeds.rb:10:in `<top (required)>'
/Users/nataliab/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `load'
/Users/nataliab/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `block in load'
/Users/nataliab/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
/Users/nataliab/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `load'
/Users/nataliab/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/engine.rb:549:in `load_seed'
/Users/nataliab/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.0.1/lib/active_record/tasks/database_tasks.rb:268:in `load_seed'
/Users/nataliab/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.0.1/lib/active_record/railties/databases.rake:196:in `block (2 levels) in <top (required)>'
/Users/nataliab/.rvm/gems/ruby-2.3.0/gems/rake-11.3.0/exe/rake:27:in `<top (required)>'
/Users/nataliab/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'
/Users/nataliab/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => db:seed
(See full trace by running task with --trace)
The error message gives you the clue:
NoMethodError: undefined method `find_or_initialize_by_title' for #<Class:0x007fb22d28f820>
Did you mean? find_or_initialize_by
The dynamic method names are now not really "Rails-approved" you should instead use find_or_initialize_by. In this case you'd use:
Scenario.find_or_initialize_by(title: s.title)
Here's a link to the api doc on this method: http://apidock.com/rails/v4.0.2/ActiveRecord/Relation/find_or_initialize_by
Try Scenario.find_or_initialize_by(title: s.title)
In my newly created Rails 4 app, I suddenly hit rails g devise install instead of rails g devise:install. After this mistake, devise components for install are generated as I understood from this output:
invoke active_record
create db/migrate/20130921224627_devise_create_installs.rb
create app/models/install.rb
insert app/models/install.rb
route devise_for :installs
When I try to roll it back like rails d migration install, it failed because of not being set config.secret_key in devise.rb, but there was no file named it, too. I can't run rails g devise:install even creating devise.rb file and adding secret key configuration. After this process, here's another error occured:
/home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:10:in `rescue in execute_if_updated': Rails::Application::RoutesReloader#execute_if_updated delegated to updater.execute_if_updated, but updater is nil: #<Rails::Application::RoutesReloader:0x007f6c66a67848 #paths=["/home/ekrem/workspace/contactman4/config/routes.rb"], #route_sets=[#<ActionDispatch::Routing::RouteSet:0x007f6c66ac1c80>]> (RuntimeError)
from /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:6:in `execute_if_updated'
from /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/application/finisher.rb:69:in `block in <module:Finisher>'
from /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `instance_exec'
from /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `run'
from /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:55:in `block in run_initializers'
from /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/tsort.rb:150:in `block in tsort_each'
from /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'
from /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/tsort.rb:219:in `each_strongly_connected_component_from'
from /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_connected_component'
from /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/tsort.rb:180:in `each'
from /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_component'
from /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each'
from /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:54:in `run_initializers'
from /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/application.rb:215:in `initialize!'
from /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /home/ekrem/workspace/contactman4/config/environment.rb:5:in `<top (required)>'
from /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
from /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
from /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
from /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
from /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/application.rb:189:in `require_environment!'
from /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:45:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
How can I correct this mistake?
There're couple ways around that, but I prefer to just remove everything that generator created.
the migration
the model
the route
I don't see you running the rake db:migrate command, so the migration might not be commited. If it is , run rake db:rollback wich will rollback the last migration.
One last thought for you. You should really learn how to use Git (or any other VCS you prefer). 'Cause it's exactly on of the problems that a VCS is designed to solve.