You're working on your Tunr app and you encounter this error. What does it mean and where would you go first to address it?
The artist index view needs to be created in the views folder. It's either missing, or routed incorrectly.
Consider this file name:
20150726145027_create_artists.rb
What is the purpose of this file, and what is the purpose of the numbers at the beginning of its name?
its a migration file, the numbers at the beginning are a time stamp / method of version control.
In a Rails application, how is the router related to controller actions?
The router takes a query from the browser and directs it to its corresponding controller.
Assuming our Tunr Rails app (1) has a Song model that belongs to an Artist model and (2) uses nested resources, which of the following helpers would create a URL that routes to songs#new
? (Select one answer)
[x] artist_song_path( @artist, @song )
[] new_artist_song_path( @artist )
[] create_artist_song_path( @artist )
[] new_artist_song_path( @artist, Song.all )
[] new_song_path( @song )
Where are (a) cookies and (b) session variables stored? (Select one answer)
[] (a) Server, (b) Browser
[] (a) Browser, (b) Database
[] (a) Database, (b) Server
[x] (a) Browser, (b) Server
Assume each Song in Tunr has an avg_rating
attribute. It is an integer from 1 to 10, and is the average rating of all of Tunr's millions of enthusiastic users.
You would like the title of each song to be displayed in a different color depending on the song's rating.
A great song like "Livin' on a Prayer" would have a rating of 10 and appear green, and a bad song like "Blurred Lines" would have a rating of 1 and appear red.
Without getting into specifics of how you would write the code itself, pick one and defend your answer:
This code would make most sense as a...
- ...model method.
- ...controller method.
- ...helper method.
To seperate concerns, a helper method would be the best action. The model should be focused purely on business logic, the controller should be focused on efficiently handling browser query's. a good helper method would be the best way to handle this additional functionality.
You clone yet another Tunr repo. Put the following commands in the correct order necessary to make the app run. Delete the one command that will not be used. #DjKhaledVoice #AnotherOne
$ git clone git@github.com:ga-wdi-exercises/moar-tunr.git
$ rake db:drop
$ rake db:create
$ rake db:migrate
$ rake db:seed
$ bundle install
$ rails s
You're a good person and decide to validate your HTML. You copy and paste the contents of app/views/artists/index.html.erb
into the validator:
<h2>Artists</h2>
<% @artists.each do |artist| %>
<div><%= link_to artist.name, artist %></div>
<% end %>
The validator throws errors at you! Why? Assuming you haven't made any mistakes in your code, how could you go about accurately validating your HTML?
Your answer...
What are two differences between the two following commands?
$ rails new tunr
$ rails new . -d postgresql
The first terminal command will make a new rails directory called tunr, it will use the default database type (not the right word for it, but it will use sqlite and not postgresql)
the second command will create a new rails directory, but it will be unamed, and will use postgresql as its database type.
Which one of the following is the most correct way to display an error message to the user?
[] @error = "Wrong password!"
[] puts "Wrong password!"
[x] flash[:alert] = "Wrong password!"
[] session[:error] = "Wrong password!"
[] render error: "Wrong password!"
[] flash[:notice] = "Wrong password!"
what exactly is the difference between using flash.notice, and flash.alert in this example?