程序代写 Creating a Ruby on Rails Application

Creating a Ruby on Rails Application
Before following these instructions please make sure you have completed the steps in the guide ¡°Getting Started with GitLab¡±.
Which repository?
When you are practising developing with Ruby on Rails (e.g. when completing worksheets) you should use your personal Git repositories. GitLab will allow you to create up to five personal projects (GitLab uses the term ¡®project¡¯ to refer to a repository).

Copyright By PowCoder代写 加微信 powcoder

Your team will be allocated a shared repository that will be used for storing the code for your team project. When you are ready to start work on this, one of the team members should be assigned the task of creating a new Rails application from the Rails template (see below) and committing it to the team repository. The other team members should then pull this from the repository.
Configuring Git
Your Git client should be configured with details about yourself so that the correct information can be associated with your commits. We will also specify that the name ¡°main¡± should be used for the default branch of any repositories you create, and that we prefer the simple push method. This only needs to be done once per machine.
Type the following commands and press enter after each, substituting values inside double quotes with your own name and University email address:
git config –global user.name “Your name”
git config –global user.email
git config –global init.defaultBranch main
git config –global push.default simple
Creating a personal repository
1. Open a web browser and navigate to:
https://git.shefcompsci.org.uk/projects/new#blank_project
2. Give your repository a suitable name (replace ¡°My awesome project¡± with a project name, e.g. ¡°Worksheet 1¡±). You should see the ¡°Project slug¡± field has been filled in with a URL compatible name.
3. Ensure the checkbox next to “Initialize repository with a README” is not ticked.
4. Click the ¡°Create project¡± button to create the personal project.

5. Your project will be created with an empty repository. Click the ¡°Clone¡± button and you will be able to copy the SSH URL of this repository, which will be needed shortly when you are ready to push your new Rails application.
Creating a new Rails application
Cloning the Rails template
When completing our worksheets or starting your team project you must generate the application using our Rails template. The template will ensure your application is configured to work with the tools we have provided, including our demo servers.
You only need to follow these steps once to create a local copy of the Rails template repository. You can then reuse the template each time you create a new Rails application.
1. If you are using macOS or Ubuntu, open a terminal. If you are using WSL2 on Windows, open VSCode and click ¡°Terminal > ¡± in the top menu.
2. Change into your home directory:
3. Clone our Rails template using the following command:
4. You may be prompted to unlock the private element of your SSH key. Type the passphrase you set when generating the SSH key and press enter.
5. A copy of the Rails template will be created in a directory called ¡°rails-template¡±.
Generating a new application
1. We will be using Rails version 6.1.4.4. Before generating a new application you should check that you are using the correct version by running the command:
If the output does not show ¡°Rails 6.1.4.4¡± please refer back to the setup guides.
2. Generate a new Rails application with our template by using the command: rails new my-project-name -m ~/rails-template/student_template.rb (substitute “my-project-name” with a suitable name, e.g. “worksheet-1”)
3. The creation process will take a few minutes to complete and various messages will be displayed. Watch out for any error messages which will require further action.

For future reference:
When you generate a new Rails application as above it will automatically run commands to set up your database and to install gems and JavaScript packages on your machine.
At other times you will clone an existing repository and these commands will need to be run manually as follows:
cp config/database_sample-pg.yml config/database.yml
bundle install
yarn install
bundle exec rails db:create
bundle exec rails db:migrate
bundle exec rails db:seed
Storing the new application in GitLab
1. In your terminal, change into your application¡¯s directory by running the command:
cd my-project-name
(substitute ¡®my-project-name¡¯ with the name you used when generating the application, e.g. “worksheet-1”)
2. You should confirm the Git status of your new application with the following command. If the error ¡°fatal: not a git repository¡± is shown this suggests the application has not been generated correctly; you will need to go back and check the output for error messages.
git status
3. To stage all files ready for committing, type the following command:
4. You can check that all files have been staged by running the following command:
git status
5. To make the initial commit of your application, run the following command:
git commit -m “Initial commit”
6. Before the initial commit can be pushed to GitLab we must make Git aware of our remote repository on GitLab. The remote should be named ¡®origin¡¯. This is done

using the command below, where you should replace ¡°URL¡± with the location of a repository in the format: You can find the path for your repository on the GitLab project page, by clicking the ¡®Clone¡¯ button and copying from the field ¡°Clone with SSH¡±. This can then be pasted into your terminal by right-clicking and selecting Paste.
git remote add origin URL
If you used the wrong repository URL, run the following command to remove the remote before adding it again:
git remote rm origin
7. Push the initial commit to GitLab using the following command:
git push -u origin main
(the parameters used in this command will be remembered, so subsequent commits can be pushed using just ¡°git push¡±).
8. You may be prompted to unlock the private element of your SSH key. Type the passphrase you set when generating the SSH key and press enter.
9. You will now be able to view your commit in the GitLab web interface (refresh the project page, and then click Activity at the top of the page to view the commit).
Running the new application
1. From your application¡¯s directory, start the Rails server with the following command:
bundle exec rails s
2. Open a separate terminal window or tab, make sure you are in your application¡¯s directory, then start the Webpack development server (which is responsible for packaging and serving the application¡¯s client side assets):
bin/webpack-dev-server
3. You should now be able to visit http://localhost:3000 in a browser to see your application.
4. To stop the Rails or Webpack servers, go to the relevant terminal window/tab and press CTRL+C.

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com