Git Product home page Git Product logo

fibonacci's Introduction

Fibonacci

Fibonacci is a recruitment exercise for Enercoop. The goal is quite simple, we have here a sample app with a very basic login, your job is to improve the sign up form. Good luck !

How to take the test ?

  • Clone this repo (do not fork it),
  • When you are ready, send via email either your github project link or your zipped directory. Do not forget to attach your .git folder :)

Install

First of all, you need to install docker-compose : https://docs.docker.com/compose/install/

Once you have docker-compose installed and running, use the docker-compose up command at the root of your project to install and launch :

  • A postgresql container named db
  • A rails container named web
  • A rubocop/guard container named rubocop

Then you need to create your database by running :

$ docker-compose run web rake db:create
$ docker-compose run web rake db:migrate

You should now be able to go to http://localhost:3000 and start coding !

Oh ! By the way, if you are not familiar with Docker and fail to run your classic rails commands, it is probably because you're not specifying the Docker container in wich to run them. As a general rule, you may want to prefix all your commands by docker-compose run web [your_command]. Or, you could launch a bash in the 'web' container and run your commands from there : docker-compose run web /bin/bash.

Note 1 : if you're using Linux, you may encounter a common DNS problem. You will know if the build fails during the apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs command. Solve this by doing :

  • Find your DNS IP : nmcli device show | grep IP4.DNS
  • Open the docker config file : sudo vim /etc/default/docker
  • Add your DNS : DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4 --dns [your_dns]"
  • Open the docker service file : sudo vim /lib/systemd/system/docker.service
  • Replace the ExecStart line with your DNS : ExecStart=/usr/bin/dockerd --dns [your_dns] --dns 8.8.8.8 --dns 8.8.4.4 -H fd://
  • Restart docker :
$ sudo service docker stop
$ systemctl daemon-reload
$ sudo service docker start

Then you need to create your database by running :

$ docker-compose run web rake db:create
$ docker-compose run web rake db:migrate

You should now be able to go to http://localhost:3000 and start coding ! If you want to stop coding, you can stop the application with Ctrl-C, or with docker-compose down.

Note 2 : if you're stopping the application with Ctrl-C, and attempt to restart it, you might get the following error:

web_1 | A server is already running. Check /myapp/tmp/pids/server.pid.

To solve this, delete the file tmp/pids/server.pid and re-start the application with docker-compose up.

For more complete infos on how to use Docker with Rails, you can read the quikstart guide here.

What is there ?

The app you've just installed has already some features. Let's see that from the Gemfile perspective ...

# Use Slim for views
gem 'slim', '~> 3.0.6'

# Use Clearance for authentication & authorization with email & password
gem 'clearance', '~> 1.16'

# SimpleForm made forms easy!
gem 'simple_form', '~> 3.5'

# Bootstrap for style
gem 'bootstrap', '~> 4.0.0.beta'

# AASM is a continuation of the acts-as-state-machine rails plugin, built for plain Ruby objects
gem 'aasm', '~> 4.12', '>= 4.12.2'

group :development, :test do
  # Rubocop is a Ruby code style checking tool
  gem 'guard', '~> 2.14', '>= 2.14.1'
  gem 'guard-rubocop', '~> 1.3'
end

If you are not familiar with these gems, you can read the docs :

Exercise

As we said earlier, your goal is to improve our sign up form.

If you go to http://localhost:3000/, you should see our home page :

Here, you should be able to click on the 'Sign up !' button, and go to the sign up page :

This is where you step in. We want you to update this very simple form into a two steps form that should look like this :

We will not tell you strong rules about how to make the form, and what it should do, just make it as good as you can. But if you don't know how to start, here are a few guidelines you can follow :

  • Set up field validations
  • Use a state machine (AASM) for the multi-step form
  • Allow the user to go back to step one
  • Use the rectify gem to dry some code
  • Check your syntax using rubocop
  • Maybe send a welcome mail using a background job
  • Maybe install rspec, export the Clearance feature specs (rails generate clearance:specs) and update them
  • Maybe allow the user to close its browser, then come back and recover his session

Now that you have done all of that, you can sign up, and if you did it well, you should see our dashboard page :

fibonacci's People

Contributors

petrachi avatar scesbron avatar soniaprevost avatar

Watchers

 avatar

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.