{"id":18247077,"url":"https://github.com/badbye/restaurant-server","last_synced_at":"2025-04-08T19:35:32.041Z","repository":{"id":66175995,"uuid":"79459124","full_name":"badbye/restaurant-server","owner":"badbye","description":null,"archived":false,"fork":false,"pushed_at":"2017-01-19T14:06:47.000Z","size":10992,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-14T15:17:24.074Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/badbye.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-19T14:04:56.000Z","updated_at":"2017-01-19T14:06:49.000Z","dependencies_parsed_at":"2023-02-21T16:45:23.511Z","dependency_job_id":null,"html_url":"https://github.com/badbye/restaurant-server","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badbye%2Frestaurant-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badbye%2Frestaurant-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badbye%2Frestaurant-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badbye%2Frestaurant-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/badbye","download_url":"https://codeload.github.com/badbye/restaurant-server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247913025,"owners_count":21017084,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T09:29:00.378Z","updated_at":"2025-04-08T19:35:32.013Z","avatar_url":"https://github.com/badbye.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Restaurant Server\n\n## What is this for?\n\nIn the previous course [HTML, CSS, and Javascript for Web Developers](https://www.coursera.org/learn/html-css-javascript-for-web-developers), since our web site did not have a feature to update the menu of the restaurant, we could get away with having a central server to request menu data for all the students in the class. However, in this course ([Single Page Web Applications with AngularJS](https://www.coursera.org/learn/single-page-web-apps-with-angularjs)), we are adding a feature for the owners of the restaurant to be able to update the menu. Since each deployed application will be able to update the data on the server, we can no longer get away with having a central one. Each student will have to set up their own server with their copy of the data to mess with.\n\n**The setup, however, is super easy! Just closely follow these steps.**\n\n## Prerequisites Before You Start\n\nThe _only_ prerequisite is that you have Git installed on your machine. If you don't, see the Development Environment Setup video in Module 1 of [Single Page Web Applications with AngularJS](https://www.coursera.org/learn/single-page-web-apps-with-angularjs).\n\nYou do NOT need to install Ruby on Rails on your local machine in order to deploy and use this application.\n\n## Step 1 - Clone This Repository\n\nOpen up the Command Prompt or cmd (on Windows) or Terminal app (if you on a Mac). Navigate (use `cd some_dir`) to a directory of your choice, preferably located in your home directory. and type following `git` command which will create a subdirectory in the directory you're in now called `restaurant-server` and download the repository code into that subdirectory.\n\n```bash\ngit clone https://github.com/jhu-ep-coursera/restaurant-server.git\n```\n\n## Step 2 - Sign Up With Heroku\n\nNow, that you have the repo, we need to deploy it somewhere on the internet. We will be using Heroku. Heroku is a cloud Platform-as-a-Service (PaaS) and it's free (they of course have paid plans, but we will be using the free plan).\n\nGo to [Heroku.com](http://www.heroku.com) and click the \"Sign Up\" button at the top right corner. After you sign up, the most important thing to remember is your username and password.\n\n## Step 3 - Download and Install Heroku Command Line Interface (CLI)\n\nHeroku Command Line Interface (CLI) is a command-line tool that will allow us to deploy our server application directly to Heroku servers. (This tool used to be called Heroku Toolbelt, so don't get confused if you see this name somewhere.)\n\nGo to https://devcenter.heroku.com/articles/heroku-command-line and install Heroku CLI by following the instructions for the Operating System you're using.\n\n## Step 4 - Log Into Heroku Using Heroku CLI\n\nRun the following in your terminal (you only actually type the FIRST line below - Heroku prompts you for the rest):\n\n```bash\nheroku login\nEnter your Heroku credentials.\nEmail: name@example.com\nPassword (typing will be hidden):\nAuthentication successful.\n```\n\nYou might not get the exact text above, but it should be something very similar.\n\n## Step 5 - Create Heroku Domain\n\nThe web application you deploy to Heroku will have the URL in the form of http://YOUR-CHOSEN-SUBDOMAIN.herokuapp.com/. Note the `YOUR-CHOSEN-SUBDOMAIN` subdomain part of the URL. In this step, we'll use the Heroku Toolbelt to allow us to choose that subdomain name. You can be the one to decide on the exact name or you can let Heroku decide for you.\n\n**NOTE! From this step forward, make sure you are located inside the `restaurant-server` directory! If not, navigate to that directory using `cd restaurant-server`.**\n\nType the following command to have Heroku generate a random subdomain name for your application:\n\n```bash\nheroku create\n```\n\nAlternatively, type the name you would like Heroku to use (as your chosen subdomain name) as follows:\n\n```bash\nheroku create ychaikin-course5\nCreating ⬢ ychaikin-course5... done\nhttps://ychaikin-course5.herokuapp.com/ | https://git.heroku.com/ychaikin-course5.git\n```\n\n## Step 6 - Deploy The App Using Git\n\nWhen you created your application, Heroku created an empty remote git repository for you. You can verify that this is indeed so by typing the following `git` command:\n\n```bash\ngit remote -v\nheroku\thttps://git.heroku.com/ychaikin-course5.git (fetch)\nheroku\thttps://git.heroku.com/ychaikin-course5.git (push)\norigin\thttps://github.com/jhu-ep-coursera/restaurant-server.git (fetch)\norigin\thttps://github.com/jhu-ep-coursera/restaurant-server.git (push)\n```\n\nYou can see that there are 2 git remotes: One is `origin` (which is the place from which you originally cloned the repository, i.e., GitHub.com), and second one called `heroku`.\n\nNow, we need to upload this repository to Heroku through `git`. Type the following command to deploy the application (which basically just takes what you have locally and pushes/uploads it out to Heroku's repository).\n\n```bash\ngit push heroku master\n```\n\nAt this point Heroku is looking at the contents of the repository you pushed to it and once it realizes that it's a Ruby on Rails application (based on the directory structure and some other obvious signs), it gladly DEPLOYS the application for you somewhere in the cloud _under the domain name you chose before_. You should see a lot of `remote` logs scroll by as Heroku deploys your application.\n\nWe are not finished yet, but if you go to http://YOUR-CHOSEN-SUBDOMAIN.herokuapp.com/menu_items.json, you should at least see an \"Internal Server Error\" with a 500 code. The reason you would be seeing an error at this point is because the application is trying to retrieve data from a database which has not been set up as of yet.\n\nIf, after going to the URL above, you see \"Heroku | No such app\" - you have missed a step somewhere or are entering a wrong URL.\n\n## Step 7 - Deploy The Database\n\nIn this step, you'll initialize the database and populate it with data.\n\nType the following command to create the database tables:\n\n```bash\nheroku run rake db:migrate\n```\n\nThen, type the following to populate the database tables with the initial data:\n\n```bash\nheroku run rake db:seed\n```\n\nYou will see lots of text scrolling by and not all of it will be legible. That's OK. We are storing images for the restaurant menu items as base64-encoded strings, so some of the data may _appear_ garbled.\n\n## Step 8 - Set Your Username/Password For Admin Portion Of The Restaurant Site\n\nIn order to modify data in the application, you will need to set up username/password.\n\nType the following command:\n\n```bash\nheroku run rails console\n```\n\nThen, when you get a prompt, type in the following:\n\n```bash\nLogin.create! identification: \"SOME_USERNAME\", password: \"SOME_PASSWORD\",  password_confirmation: \"SOME_PASSWORD\"\n```\n\nYou can copy/paste this line and then replace SOME_USERNAME and SOME_PASSWORD with whatever username/password you'd like to use when you log into the administrative portion of our restaurant web application.\n\nAfter the username/password is set, type `exit` to quit the rails console.\n\n**That's it! DONE! You are now ready to use this remote server for your copy of the restaurant web application.**\n\n## Want To Learn How To Make This Ruby on Rails Application Yourself?\n\nIn this class, we are not covering any server-side development. However, if you'd like to acquire the skills necessary to produce an application like this on your own, check out the first 2 courses in this specialization: [Ruby on Rails: An Introduction](https://www.coursera.org/learn/ruby-on-rails-intro) and [Rails with Active Record and Action Pack](https://www.coursera.org/learn/rails-with-active-record). Those courses are taught by [Kalman Hazins](https://www.coursera.org/instructor/kalman-hazins), who developed this restaurant-server app.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbadbye%2Frestaurant-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbadbye%2Frestaurant-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbadbye%2Frestaurant-server/lists"}