fork-commit-merge / fork-commit-merge

Fork, Commit, Merge. A project designed to help you familiarize yourself with the open source contribution workflow on GitHub!

Home Page:https://forkcommitmerge.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fork, Commit, Merge - Easy Issue (Rails)

nikohoffren opened this issue · comments

Fork, Commit, Merge - Easy Issue (Rails)

Create a Simple "Hello, Rails!" App in Ruby on Rails

Note: You don't have ask permission to start solving the issue or get assigned, since these issues are supposed to be always open for new contributors. The actions-user bot will reset the file back to previous state for the next contributor after your commit is merged. So you can just simply start working with the issue right away!

How to get started:

Open the tasks/rails/easy directory from the root of your project.
Then start implementing your solution!

Objective:

Create a basic Ruby on Rails application that displays "Hello, Rails!" when visiting the home page.

Requirements:

  • Set up a new Rails application.
  • Generate a controller called Welcome.
  • Create an action index in the Welcome controller.
  • Add a view for the index action that displays "Hello, Rails!".
  • Set the route for the home page to point to the Welcome#index action.

Instructions:

First, make sure you are in the correct directory:

cd tasks/rails/easy

To create a new Rails application, you can use the following command:

rails new hello_rails

This will create a new directory called hello_rails containing a new Rails application. You can then navigate into your new app's directory:

cd hello_rails

To generate a new controller called Welcome, run:

rails generate controller Welcome

After that, you'll want to edit the app/controllers/welcome_controller.rb file to add an index action. Then, you'll also add a corresponding view in app/views/welcome/index.html.erb that displays "Hello, Rails!".

Finally, you can set the root URL of your application to point to this index action by editing config/routes.rb:

Rails.application.routes.draw do
  root 'welcome#index'
end

Now, you should be able to run your Rails application and see "Hello, Rails!" when you visit http://localhost:3000. To start the server, use:

rails server

To work with this issue, you need to have Ruby and Rails installed to your local machine.
Check out README.md for more instructions of installing Ruby and Rails and how to make a pull request.

Feel free to ask any questions here if you have some problems!

Also, kindly give this project a star to enhance its visibility for new developers!