learn-co-curriculum / active-record-association-methods Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
After rake console, the id returned should be 1 and not nil
I got a return of id:1 in my terminal by following precisely. I asked AAQ Tech Coach why because I'm trying to understand.
Association Methods
Go ahead and run the test suite and you'll see that we are passing the first 14 tests. Our associations are all working, just because of our migrations and use of macros.
We can now call methods on the objects we associated with one another. Let's play around with our code using the console task we wrote for you in the Rakefile.
rake console
hello = Song.create(name: "Hello")
=> #<Song:0x007fc75a8de3d8 id: nil, name: "Hello", art
Our migrate_db
method and db:migrate
tasks are error prone.
We should just use the rake tasks provided by sinatra-activerecord and deprecate rolling our own migration tasks. We'd also have to use database_cleaner in the tests. While we're at it, throw require_all
that way all labs are adopting these three gems as patterns.
Performed trouble shooting with student. Migrations ran out of order.
for drake_made_this, i would suggest adding a test that fails if the student tries:
def drake_made_this
# when this method is called it should assign the song's artist to Drake
self.artist = Artist.new(name: "Drake")
end
end
Not sure if this is related to Nitrous or what, but having issues with the gems.
Just re-forked/cloned the lab, ran bundle install (installing 22 gems), then rake db:migrate, and got
➜ Active-Record-Association-Methods-v-000 git:(master) ✗ rake db:migrate
Could not find pry-0.10.1 in any of the sources
Run bundle install
to install missing gems.
Ran bundle update, then rake db:migrate again:
➜ Active-Record-Association-Methods-v-000 git:(master) ✗ rake db:migrate
Could not find activemodel-4.2.6 in any of the sources
Run bundle install
to install missing gems.
Tried this again, and it's still stuck on activemodel-4.2.6.
Tried deleting the gemfile.lock and rerunning, but same errors.
I've been trying to do this lab since January, and back then I ran into issues with the migrations not loading in the correct order. It's the same issue seen here: #5
I took a break and came back to this lab. This gem problem I'm describing didn't start until about a month ago or so.
Hi, you may want to consider re-writing the test for "drake_made_this" which is the last test for this lab. The instructions never explicitly says to return an artist from the method, but the test requires that an artist with the name of "Drake" is returned. Furthermore, that return value of the method is the only thing being tested, so you can actually pass the test without properly setting the song's artist as long as the method returns an Artist whose name is Drake. I passed the tests using just one line in the last method: Artist.find_or_create_by(name: "Drake"), which clearly doesn't change the song's artist. Thanks!
when running 'learn', was prompted to add "learn-co" gem to gem file.
// ♥ learn
/Users/BradSmith/.rvm/gems/ruby-2.2.3/gems/bundler-1.11.2/lib/bundler/rubygems_integration.rb:304:in block in replace_gem': learn-co is not part of the bundle. Add it to Gemfile. (Gem::LoadError) from /Users/BradSmith/.rvm/gems/ruby-2.2.3/bin/learn:22:in
eval' from /Users/BradSmith/.rvm/gems/ruby-2.2.3/bin/ruby_executable_hooks:15:in
'After adding it, was able to run 'learn', but still got the following message:
// ♥ learn submit
Adding changes...
Committing changes...
Pushing changes to GitHub...
Submitting lesson...
Done.
bash: parse_git_branch: command not found
[21:32:45] Active-Record-Association-Methods-v-000
Can it be made explicit that Drake does not exist in the db for this test? Also more clarity on return values would be great, as according to the wording of the test
self.artist = Artist.find_by(name: "Drake")
should work, but I could only get self.artist = Artist.find_or_create_by(name: "Drake")
to pass the test.
Thanks!
Just started with "bundle install" and when I run rake db:migrate, getting this:
➜ Active-Record-Association-Methods-v-000 git:(master) ✗ rake db:migrate
== CreateGenres: migrating ===================================================
-- create_table(:genres)
-> 0.0076s
== CreateGenres: migrated (0.0078s) ==========================================
== AddGenreToSongs: migrating ================================================
-- add_column(:songs, :genre_id, :integer)
rake aborted!
SQLite3::SQLException: no such table: songs: ALTER TABLE "songs" ADD "genre_id" integer
when I run rake db:migrate I'm getting an error that json 1.8.3 is not installed
so I tried to manually "bundle install" as well as a direct "gem install json -v '1.8.3'"
with no success. in the end I had to run "bundle update" to resolve the situation, so it seems that the preexisting "gemfile.lock" file needs a update.
THANKS
The lab says that we should be able to run rake db:migrate the first thing in the lab, but when I run it, none of the tests pass and it throws a lot of errors. Can you please fix this?
what what.... a dependency error with rake? wuuhhhh.... no way!
In the middle of working through rspeclementing this lab, I took a moment to create a new branch, committed a suggested improvement to it, and created a pull request for it. After doing this and refreshing the lab page on Learn, the Learn web app marked the lab as completed - even though some of my tests are still failing.
The web app should not mark a lab as completed if the code in the latest pull request submitted by the user isn't passing all the tests, or if not that, then at least it shouldn't mark a lab as completed until student has done at least one run of learn where all tests pass at the same time.
Active-Record-Association-Methods-v-000 git:(master) ✗ rake db:migrate
== CreateGenres: migrating ===================================================
-- create_table(:genres)
-> 0.0070s
== CreateGenres: migrated (0.0072s) ==========================================
== AddGenreToSongs: migrating ================================================
-- add_column(:songs, :genre_id, :integer)
rake aborted!
The last test fails because no Artist instance is created in the specfile. This can be corrected by adding
@drake = Artist.create(name: "Drake")
inside of the before
statement in 09_song_methods_spec.rb
when opening the ide for this lab, it returns an error
learn open Active-Record-Association-Methods-online-web-ft-090919 Looking for lesson... Hmm...Cannot find lesson with repo: active-record-association-methods-online-web-ft-090919. Please check your input and try again.
I am able to clone the lab directly, but then am unable to cd into the lessons directory to run learn. All other labs open as expected.
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.