learn-co-curriculum / phase-3-active-record-intro-to-rake Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
Fix: need to update the environment.rb
to require dependencies using Bundler.require
Hi! In spanish, it would actually be "hola desde Rake" :)
https://learning.flatironschool.com/courses/5286/assignments/172676?module_item_id=376756
Here's my entire script:
# NOTE: If we then use the command, 'rake hello' in another terminal, we the return the 'puts' output below
# It's basically Ruby's version of the 'Makefile' / Crontab jobs
# NOTE: By adding a 'namespace', we can group our related Rake tasks together:
namespace :greeting do
# NOTE: If we use 'rake -T', this will list the available 'Rake' tasks and their descriptions:
desc 'outputs hello to the terminal'
task :hello do
puts "hello from Rake!"
end
desc 'outputs hola to the terminal'
task :hola do
puts "hola desde Rake!"
end
end
# NOTE: We can use these individual tasks using the 'namespace:rake_task' syntax:
# rake greeting:hello
# rake greeting:hola
# NOTE: If you encounter this error:
# rake aborted!
# Gem::LoadError: You have already activated rake 10.4.2,
# but your Gemfile requires rake 10.4.0.
# Prepending `bundle exec` to your command may solve this.
# Then, use this command as the fix:
# bundle exec rake greeting:hello
# NOTE: We will now use the 'rake db:migrate' command to create a database table and migrate the code using
# a 'rake' task:
namespace :db do
task :environment do
require_relative "./config/environment"
end
desc "migrate changes to your database"
# NOTE: This line creates a task dependency to force the rake task to run the ':environment' task
# BEFORE running the 'migrate' task:
task migrate: :environment do
Student.create_table
end
desc "seed the database with some dummy data"
task seed: :environment do
require_relative "./db/seeds"
end
end
desc "drop into the Pry console"
task console: :environment do
Pry.start
end
If I run the 'bundle exec rake console' command after running the 'rake db:migrate' and 'rake db:seed' commands respectively, I get this error:
samuelbanya@Samuels-MBP ~/hub/Development/code/phase-3/phase-3-active-record-intro-to-rake $ bundle exec rake console
rake aborted!
Don't know how to build task 'environment' (See the list of available tasks with `rake --tasks`)
Did you mean? db:environment
/Users/samuelbanya/.gem/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
/Users/samuelbanya/.gem/gems/bundler-2.2.23/lib/bundler/cli/exec.rb:63:in `load'
/Users/samuelbanya/.gem/gems/bundler-2.2.23/lib/bundler/cli/exec.rb:63:in `kernel_load'
/Users/samuelbanya/.gem/gems/bundler-2.2.23/lib/bundler/cli/exec.rb:28:in `run'
/Users/samuelbanya/.gem/gems/bundler-2.2.23/lib/bundler/cli.rb:474:in `exec'
/Users/samuelbanya/.gem/gems/bundler-2.2.23/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/Users/samuelbanya/.gem/gems/bundler-2.2.23/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/Users/samuelbanya/.gem/gems/bundler-2.2.23/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/Users/samuelbanya/.gem/gems/bundler-2.2.23/lib/bundler/cli.rb:30:in `dispatch'
/Users/samuelbanya/.gem/gems/bundler-2.2.23/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/Users/samuelbanya/.gem/gems/bundler-2.2.23/lib/bundler/cli.rb:24:in `start'
/Users/samuelbanya/.gem/gems/bundler-2.2.23/exe/bundle:49:in `block in <top (required)>'
/Users/samuelbanya/.gem/gems/bundler-2.2.23/lib/bundler/friendly_errors.rb:128:in `with_friendly_errors'
/Users/samuelbanya/.gem/gems/bundler-2.2.23/exe/bundle:37:in `<top (required)>'
/Users/samuelbanya/.rvm/gems/ruby-2.7.4/bin/bundle:25:in `load'
/Users/samuelbanya/.rvm/gems/ruby-2.7.4/bin/bundle:25:in `<main>'
/Users/samuelbanya/.rvm/gems/ruby-2.7.4/bin/ruby_executable_hooks:22:in `eval'
/Users/samuelbanya/.rvm/gems/ruby-2.7.4/bin/ruby_executable_hooks:22:in `<main>'
Tasks: TOP => console
(See full trace by running task with --trace)
No response
No response
https://learning.flatironschool.com/courses/4980/assignments/169129?module_item_id=366662
This has been the case on the last few labs, but this is the first one where it's really a pain because it shows up every time we type something in the CLI. When i run 'bundle install' as well as every time I run a rake script, I get this:
Calling DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call
DidYouMean.correct_error(error_name, spell_checker)' instead.
No response
No response
I'm trying to use the console task to drop into a Pry console, but it's not working. I get the following error:
rake aborted!
Don't know how to build task 'environment' (See the list of available tasks with `rake --tasks`)
Did you mean? db:environment
The correct code should be:
desc 'drop into the Pry console'
task :console do
require_relative './config/environment'
Pry.start
end
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.