You are currently viewing ruby on rails linkedin assessment answers
ruby on rails linkedin assessment answers_theanswershome

ruby on rails linkedin assessment answers

1. Which choice is not a valid Rails route?

  • root “products/index”
  • route “products/index”, to: “products/index”, via::get
  • match “products/index”, to: “products#index”, via::get
  • get “products/index”

2. What decides which controller receives which requests?

  • web server
  • view
  • router
  • model

3. Given this code, and assuming ?user is an instance of User that has an assigned location, which choice would be used to return the user's citv?

  • @user.user_city
  • @user.location_city
  • @user.try(:city)
  • @user.city

4. Given this Category model with an attribute for "name", what code would fill in the blank so that it sets saved name to a string that is the category name that existed before the name was changed?

  • category.name_changed?
  • category.name_was
  • category.saved(:name)
  • category.changes[: name ]

5. How would you validate that a project's name is not blank, is fewer than 50 characters, and is unique?

6. Which choice best describes the expected value of result?

@result = Article.first.tags.build (name: 'Urgent')

  • an unsaved Tag instance
  • either true or false
  • a saved Tag instance
  • an array of Tag instances

7. After this migration has been executed, which statement would be true?

  • The galleries table will have no primary key.
  • The galleries table will include a column named “updated at”
  • The galleries table will contain exactly seven columns.
  • The galleries table will have an index on the position column.

8. If the only route defined is resources :products, what is an example of a URL that could be generated by this link to method?

link to('Link', {controller: 'products', action: 'index', page: 3 })

  • /products/index/page=3
  • /products/index/3
  • /products?page=3
  • /products/page/3

9. Which code sample will skip running the login required "before" filter on the get posts controller action?

  • before_action :login_required, skip: (:get_posts]
  • skip_before_action :login_required, only:[:get_posts]
  • skip_before_action : login_required, except:
    [:get_posts]
  • skip_action before: :login_required, only:
    [:get_posts]

10. Which choice is an incorrect way to render a partial?

11. There is a bug in this code. The logout message is not appearing on the login template. What is the cause?

  • The string assigned to flash[:notice] will not be available until the next browser request.
  • The previous value of flash[:notice ] will not be cleared automatically.
  • This is an invalid syntax to use to assign values to flash[: notice].
  • An instance variable should be used for flash[: notice].

12. Which choice would you not consider when selecting a gem for your project?

  • how long pull requests and issues stay open
  • how many downloads it has on Ruby Toolbox
  • if it is well documented
  • the date it was first released

13. This user model has a profile image. Which code will add an Active Storage callback that deletes both the profile image record and the file after the user is deleted?

14. You are using a serializer to render a pet's data as JSON. What line would you add to include the pet owner's details as part of the feed?

15. Which line of inquiry would you follow after receiving this error message: No route matches [POSTI "/burrito/create"?

  • Check that there is a get route that matches “burrito/create” in your paths.rb file.
  • Check that there is a matching path for “/burrito/create” in your paths.rb file.
  • Add the line resources :burritos to your routes.rb file.
  • Check that there is a post route that matches “burrito/create” in your routes.rb file.

Leave a Reply