Giter VIP home page Giter VIP logo

rails-hello-world-lab's Introduction

Rails Hello World Lab

In this lab you will integrate a static route so that the application will render a "Hello World" page.

Objectives

  1. Draw a route
  2. Map a route to a controller/action
  3. Render (implicitly or explicitly) a static template
  4. Create a static template

Instructions

Below are the tasks that you will need to complete in order to finish the lab:

  • Integrate a route for localhost:3000/hello_world.

  • Create a static controller that inherits from the application controller and contains the hello_world action. You can have the call to the view file occur using either the implicit or explicit processes.

  • Create a file in the views directory that will be called by the static controller's hello_world action, and add the heading <h1>Hello World</h1> to the file. The test is case sensitive, so make sure you enter it exactly as shown.

The RSpec/Capybara test suite is currently not passing. Run the tests to see what you need to fix. It might be helpful to fire up the Rails server (via the rails s command) in order to manually test the functionality of your route, action, and view. For students in the IDE, here's a Help Center article if you run into trouble with rails s.

Demo Screenshot

Note: From this point forward, labs will not always be provided as a blank slate, with the responsibility for creating migrations, models, controllers, etc. falling on you. Instead, many labs will contain broken or incomplete code, and you will be required to add to or fix the existing code in order for the specs to pass. In some cases, code that you wrote in a previous lab will be provided. This way, you can focus on applying new concepts instead of getting bogged down in repetitive work, such as setting up a basic Rails app for every new lab. In other cases, you will be gaining the practical experience of learning how to work within an existing code base, which is what you will likely experience at your first job. Rare is the junior developer who gets to create from whole cloth: it’s far more likely that you’ll be onboarded to a project with unfamiliar code created by other developers. Always use the specs to guide you through what additions and/or modifications are needed, and remember: you do not have to run the specs in the order provided in the lab. Work on your troubleshooting chops!

rails-hello-world-lab's People

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rails-hello-world-lab's Issues

sqlite3 gem error on freshly cloned lab

Running learn on a freshly cloned copy of this lab throws this error:

An error occurred while loading ./spec/features/hello_world_spec.rb.
Failure/Error: ActiveRecord::Migration.maintain_test_schema!

Gem::LoadError:
  Specified 'sqlite3' for database adapter, but the gem is not loaded. Add `gem 'sqlite3'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).
# /Users/ian/.rvm/gems/ruby-2.3.4/gems/activerecord-5.0.7.1/lib/active_record/connection_adapters/connection_specification.rb:176:in `rescue in spec'
# /Users/ian/.rvm/gems/ruby-2.3.4/gems/activerecord-5.0.7.1/lib/active_record/connection_adapters/connection_specification.rb:173:in `spec'
# /Users/ian/.rvm/gems/ruby-2.3.4/gems/activerecord-5.0.7.1/lib/active_record/connection_handling.rb:53:in `establish_connection'
# /Users/ian/.rvm/gems/ruby-2.3.4/gems/activerecord-5.0.7.1/lib/active_record/railtie.rb:125:in `block (2 levels) in <class:Railtie>'
# /Users/ian/.rvm/gems/ruby-2.3.4/gems/activesupport-5.0.7.1/lib/active_support/lazy_load_hooks.rb:69:in `instance_eval'
# /Users/ian/.rvm/gems/ruby-2.3.4/gems/activesupport-5.0.7.1/lib/active_support/lazy_load_hooks.rb:69:in `block in execute_hook'
# /Users/ian/.rvm/gems/ruby-2.3.4/gems/activesupport-5.0.7.1/lib/active_support/lazy_load_hooks.rb:60:in `with_execution_control'
# /Users/ian/.rvm/gems/ruby-2.3.4/gems/activesupport-5.0.7.1/lib/active_support/lazy_load_hooks.rb:65:in `execute_hook'
# /Users/ian/.rvm/gems/ruby-2.3.4/gems/activesupport-5.0.7.1/lib/active_support/lazy_load_hooks.rb:50:in `block in run_load_hooks'
# /Users/ian/.rvm/gems/ruby-2.3.4/gems/activesupport-5.0.7.1/lib/active_support/lazy_load_hooks.rb:49:in `each'
# /Users/ian/.rvm/gems/ruby-2.3.4/gems/activesupport-5.0.7.1/lib/active_support/lazy_load_hooks.rb:49:in `run_load_hooks'
# /Users/ian/.rvm/gems/ruby-2.3.4/gems/activerecord-5.0.7.1/lib/active_record/base.rb:324:in `<module:ActiveRecord>'
# /Users/ian/.rvm/gems/ruby-2.3.4/gems/activerecord-5.0.7.1/lib/active_record/base.rb:24:in `<top (required)>'
# /Users/ian/.rvm/gems/ruby-2.3.4/gems/activesupport-5.0.7.1/lib/active_support/dependencies.rb:293:in `require'
# /Users/ian/.rvm/gems/ruby-2.3.4/gems/activesupport-5.0.7.1/lib/active_support/dependencies.rb:293:in `block in require'
# /Users/ian/.rvm/gems/ruby-2.3.4/gems/activesupport-5.0.7.1/lib/active_support/dependencies.rb:259:in `load_dependency'
# /Users/ian/.rvm/gems/ruby-2.3.4/gems/activesupport-5.0.7.1/lib/active_support/dependencies.rb:293:in `require'
# /Users/ian/.rvm/gems/ruby-2.3.4/gems/activerecord-5.0.7.1/lib/active_record/migration.rb:591:in `maintain_test_schema!'
# ./spec/rails_helper.rb:28:in `<top (required)>'
# ./spec/features/hello_world_spec.rb:1:in `require'
# ./spec/features/hello_world_spec.rb:1:in `<top (required)>'
# ------------------
# --- Caused by: ---
# Gem::LoadError:
#   can't activate sqlite3 (~> 1.3.6), already activated sqlite3-1.4.0. Make sure all dependencies are added to Gemfile.
#   /Users/ian/.rvm/gems/ruby-2.3.4/gems/activerecord-5.0.7.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:7:in `<top (required)>'
No examples found.

Finished in 0.03354 seconds (files took 6.18 seconds to load)
0 examples, 0 failures, 1 error occurred outside of examples

Reported by @RachelWyatt.

local test

I ran capybara test: RAILS_ENV=test rspec spec/features/hello_world_spec.rb and it passed without errors in IDE, but message in browser states that local test failed and I can't continue with lesson (I also submitted 3rd step and it's validated)

bundler issue

Bundler could not find compatible versions for gem "bundler":
In Gemfile:
rails (~> 4.2) was resolved to 4.2.11, which depends on
bundler (>= 1.3.0, < 2.0)

Current Bundler version:
bundler (2.0.1)
This Gemfile requires a different version of Bundler.
Perhaps you need to update Bundler by running gem install bundler?

Could not find gem 'bundler (>= 1.3.0, < 2.0)', which is required by gem 'rails
(~> 4.2)', in any of the sources.

The Desired Solution is Very Specific

Hey there,

I just wanted to say that the passing solution requires a specific file system set up and the test will not pass unless those specifics are met. For example, if you don't have a folder named hw in your view folder views/hw/hello_world.html.erb the test will not pass. Seems a bit arbitrary if the page renders correctly. If you want the files that specific way, it may be helpful to include directions or build the folders in there prior to the user forking/cloning the lab.

Best,
A

Routing error with the syntax in the read me

If I type get 'hello_world' to: "static#hello_world" I get the following error.

Failure/Error: require File.expand_path('../../config/environment', FILE)

SyntaxError:
/Users/josephquattrone/Desktop/Coding/Learn/rails-hello-world-lab-online-web-ft-112618/config/routes.rb:3: syntax error, unexpected tIDENTIFIER, expecting keyword_end
get 'hello_world' to: "static#hello_world"

Deprecated Gem not sure if it matter

DEPRECATION WARNING: The factory_girl gem is deprecated. Please upgrade to factory_bot. See https://github.com/thoughtbot/factory_bot/blob/v4.9.0/UPGRADE_FROM_FACTORY_GIRL.md for further instructions. (called from require at /Users/rogerperez/.rvm/rubies/ruby-2.3.3/lib/ruby/site_ruby/2.3.0/bundler/runtime.rb:81)
Array values in the parameter to Gem.paths= are deprecated.
Please use a String or nil.
An Array ({"GEM_PATH"=>["/Users/rogerperez/.rvm/gems/ruby-2.3.3", "/Users/rogerperez/.rvm/gems/ruby-2.3.3@global"]}) was passed in from bin/rake:3:in `load'
Running via Spring preloader in process 30301

Rails Static Request

The lab before rails hello world, rails static request, throws a 500 error. Reloading, closing and reopening the browser, and deleting cache didn't fix the issue.

Screen Shot 2019-11-12 at 4 11 11 PM

Screen Shot 2019-11-12 at 4 14 25 PM

Issue with instructions

Current:

Create a static controller that inherits from the application controller and contains the hello_world action. You can have the call to the view file occur using either the implicit or explicit processes.
Create a file in the views directory that will be called by the static controller's hello_world action, and add the heading Hello World to the file. The test is case sensitive, so make sure you enter it exactly as shown.

update

Create a StaticController that inherits from the application controller and contains the hello_world action. You can have the call to the view file occur using either the implicit or explicit processes.
Create a static folder within the views directory. Within that folder you will create a file that will be called by the static controller's hello_world action, and add the heading Hello World to the file. The test is case sensitive, so make sure you enter it exactly as shown.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.