learn-co-curriculum / namespaced-routes-lab Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
Let me start by saying that this is essentially the same issue that was raised here: learn-co-students/namespaced-routes-lab-v-000#1027
I'm currently stuck on this lab because I don't understand how Preferences are supposed to affect Songs and Artists.
According to the README and tests, each Preference has two attributes: allow_create_artists
and allow_create_songs
, both of which can be set to true or false. The README also says that "...There will only be 1 instance of Preference
, not a preference associated with each artist/song."
The tests also specify that there needs to be an index file for Preferences. Additionally, the artists_controller_spec and songs_controller_spec files have these lines of code:
#artists_controller_spec.rb
describe "GET new" do
it "redirects when access is turned off" do
p = Preference.create(allow_create_artists: false)
get :new
expect(response).to redirect_to artists_path
end
end
#songs_controller_spec.rb
describe "GET new" do
it "redirects when access is turned off" do
p = Preference.create(allow_create_songs: false)
get :new
expect(response).to redirect_to songs_path
end
end
So, all that said, here's what I'm unclear on: How are the ArtistsController and SongsController supposed to know that they need to redirect from their new
actions when a new Preference has been created?
@scottcreynolds hey scott, i missed this in my review but if you run rspec on the clean master branch you end up passing a lot of the tests. i'm not sure if some of the tests are old from the last lab or if there's not supposed to be any starter code. figured it'd be a lot easier for you to take a look rather than me guessing.
I feel like I cheated the solution to get the tests to pass. So I looked at the solution to compare my code and I didn't really see any solution/change to original code. I am very confused as to what exactly I should be learning from this lab.
Hello! I didn't see any specs for the 7th requirement (regarding the ordering of artists and songs according to a preference). Also, some explanation about the relationship between preferences and the other models would be useful . . .
Maybe we can bring the instructions up a level? So more like user stories, and less prescriptive?
Situation : After reading the readme, I then follow the tests and only refer back to the readme if I get stuck and am searching for further information.
Issue? : I reached the end of the "failed" tests and noticed (after checking because I briefly thought I was going crazy) that the "7) Update the artists and songs index pages to order by name according to each preference" instruction did not have a test.
I don't know if this was intentional or not but the majority of the solution for this lab was already completed. The only code I had to write in order to pass all of the tests was only what was declared in Number 4 of the instructions:
After opening the lab and running rake db:seed
i got the following errors:
rake aborted!
LoadError: cannot load such file -- active_storage/engine
/Users/heathermiller/.rvm/gems/ruby-2.5.3/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
/Users/heathermiller/.rvm/gems/ruby-2.5.3/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
/Users/heathermiller/.rvm/gems/ruby-2.5.3/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:80:in `register'
/Users/heathermiller/.rvm/gems/ruby-2.5.3/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
/Users/heathermiller/.rvm/gems/ruby-2.5.3/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:36:in `rescue in require'
/Users/heathermiller/.rvm/gems/ruby-2.5.3/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:25:in `require'
/Users/heathermiller/.rvm/gems/ruby-2.5.3/gems/activesupport-5.0.7.1/lib/active_support/dependencies.rb:293:in `block in require'
/Users/heathermiller/.rvm/gems/ruby-2.5.3/gems/activesupport-5.0.7.1/lib/active_support/dependencies.rb:259:in `load_dependency'
/Users/heathermiller/.rvm/gems/ruby-2.5.3/gems/activesupport-5.0.7.1/lib/active_support/dependencies.rb:293:in `require'
/Users/heathermiller/flatiron/namespaced-routes-lab-v-000/config/application.rb:8:in `<top (required)>'
/Users/heathermiller/flatiron/namespaced-routes-lab-v-000/Rakefile:4:in `require'
/Users/heathermiller/flatiron/namespaced-routes-lab-v-000/Rakefile:4:in `<top (required)>'
/Users/heathermiller/.rvm/gems/ruby-2.5.3/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
/Users/heathermiller/.rvm/gems/ruby-2.5.3/bin/ruby_executable_hooks:24:in `eval'
/Users/heathermiller/.rvm/gems/ruby-2.5.3/bin/ruby_executable_hooks:24:in `<main>'
So I tried commenting out #require 'active_storage/engine'
in config/application.rb but then I get the error:
rake aborted!
NoMethodError: undefined method `load_defaults' for #<Rails::Application::Configuration:0x00007fb26ed473f8>
/Users/heathermiller/.rvm/gems/ruby-2.5.3/gems/railties-5.0.7.1/lib/rails/railtie/configuration.rb:95:in `method_missing'
/Users/heathermiller/flatiron/namespaced-routes-lab-v-000/config/application.rb:23:in `<class:Application>'
/Users/heathermiller/flatiron/namespaced-routes-lab-v-000/config/application.rb:21:in `<module:DisplayingAssociationsRailsLab>'
/Users/heathermiller/flatiron/namespaced-routes-lab-v-000/config/application.rb:20:in `<top (required)>'
/Users/heathermiller/flatiron/namespaced-routes-lab-v-000/Rakefile:4:in `require'
/Users/heathermiller/flatiron/namespaced-routes-lab-v-000/Rakefile:4:in `<top (required)>'
/Users/heathermiller/.rvm/gems/ruby-2.5.3/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
/Users/heathermiller/.rvm/gems/ruby-2.5.3/bin/ruby_executable_hooks:24:in `eval'
/Users/heathermiller/.rvm/gems/ruby-2.5.3/bin/ruby_executable_hooks:24:in `<main>'
(See full trace by running task with --trace
After this, every google rabbit hole I start going down just leads me to more errors
I already made a comment on someone else's issue here, but I wanted to create an individual issue because I am not sure if the curriculum team is alerted based on new issues raised, or new comments. It's pretty clear by the number of issues students have raised about this lab that the curriculum people need to be alerted.
The instructions are terribly unclear. It's frustrating because I really want to practice my skills on the topic.
When you first try to run the tests, you get this error:
An error occurred while loading ./spec/controllers/admin/preferences_controller_spec.rb.
Failure/Error: require File.expand_path('../../config/environment', FILE)LoadError:
cannot load such file -- active_storage/engine
My students let me know that using the latest version of rails instead of 5.0.7.1, and adding gem 'listen'
to the gemfile will fix this issue, but I'm not sure why that works exactly, or if that's a solution that will work in perpetuity.
#staff
The README on the Learn.co website is different from the README file in the Github repo. It might be confusing because the former README doesn't mention SettingsController and AccessController.
It was pretty unclear that there was only going to be 1 instance of Preference rather than a preference associated w each artist/song with a has_many belongs_to relationship.
There's currently no RSpec test for 3. Update the artists and songs index pages to order by name according to each preference.
this cloned lab has almost all of the steps already finished for us.
my tests passed and I checked the solutions after.. and there's a bunch of code in the controllers that I did have to put in for the tests to pass .. just FYI
In this spec file i commented out line 43 because, according to the tech coach, the code is doing what it's supposed to be doing, but the test is still not passing.
Failures:
SongsController GET show with artist redirects to artists songs when artist song not found
Failure/Error: expect(controller).to set_flash[:alert]
NameError:
undefined local variable or method `set_flash' for #RSpec::ExampleGroups::SongsController::GETShowWithArtist:0x007fab86807850
#6 On this lab's ReadMe states:
Create a PreferencesController, routes, and views to manage the preferences. Do this under an Admin module to separate it from the standard user functionality. The artists and songs index pages should order by name according to each preference.
However, there are no requirements that we put anything in the index pages to order the songs/artist by name. I may be misinterpreting what #6 is saying, but I assumed there would be some sort of test to check Preference.song_sort_order and Preference.artist_sort_order.
Hi. The README says that after we create the Preference model, we have to "run rake preferences:load
so that your code will work in the browser".
However, after creating that model and migrations, migrating my database, and running that Rake command, I got this error in my console:
rake aborted!
Don't know how to build task 'preferences:load' (See the list of available tasks with `rake --tasks`)
So, here's my question: What is rake preferences:load
supposed to do?
---Sdcrouse
You really should redo the whole rails section
Hello! I don't think the tests for this lab are checking that the index pages for Artists and Songs are being sorted according to the Preferences. Thanks!
Update the artists and songs index pages to order by name according to each preference.
From the directions on the README it seems like you want us to update the Artist and Song index views. However, the tests did not test for views and the solution did not make changes to the view pages so this direction is confusing.
The first line of this spec should read "RSpec.describe Admin::SettingsController, type: :controller do", not "RSpec.describe Admin::AccessController, type: :controller do"
Running a single feature spec file or individual specs causes the error "Uninitialized Constant Artist". This has something to do with how the database cleaning is being handled. The specs should be able to run independently by file and by spec.
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.