Creating a simple To-Do app using Rails


Hello! Just thought I'd show how to make a very simple todo app with Rails. ๐Ÿ˜ƒ


To start using Rails you will need to following installed:

  • Ruby
  • SQLite3

Installation will vary depending on the OS you're using so I recommend looking at the following guides:

Ruby: SQLite3:

Then to install Rails you just need to run the following command:

gem install rails

Creating the simple To-Do application

First we need to create the rails application, which can be done with the following command: (I've added some options because we don't need everything)

rails new todo --skip-action-mailer --skip-action-mailbox --skip-action-text --skip-active-storage --skip-action-cable

If all goes well you should see a "todo" directory in the current workspace.

cd todo

Next we will using generate to create the bolierplate code, which saves us having to write anything. Using scaffold gives us a full set of model, database migration for that model, controller to manipulate it, views to view and manipulate the data and a test suite. In simple terms it does all the hard work for us. ๐Ÿ˜Ž

./bin/rails generate scaffold task content:text

The above command creates a resource called task with one property called content which is of type text.

Next we need to create a database for the application, which can easily be done via the following command:

./bin/rails db:create

Next we need to migrate the database which can be done via the following:

./bin/rails db:migrate

Finally we just need to run the rails server.

./bin rails s

Now if you navigate your browser to "http://localhost:3000/tasks", you should see the following page:

Tasks Page

If you click on "New task" it should take you to the following page where you can create a new task.

New Task

Feel free to try putting some text in and then click on "Create task", if successfull you should see that the task was created successfully.

New Task Created

Finally if you go back to the tasks page you should see the newly created task.


You can also Edit and Delete tasks etc. Pretty simple UI put this is how you can implement a very simple todo app with Rails, also no code required ๐Ÿ˜„


Here I have shown how to create a very simple todo application with Rails with just the command line. It's been a long time since I've used Rails, but hopefully this helps someone getting started with the Framework. ๐Ÿ˜€

Like me work? I post about a variety of topics, if you would like to see more please like and follow me. Also I love coffee.

โ€œBuy Me A Coffeeโ€