# Marin Belec_

home about projects contact & links posts crypto

How to create a Ruby on Rails website using Hotwire

  1. Install Ruby and Rails on your system. Use rvm. \curl -sSL https://get.rvm.io | bash -s stable --rails then

  2. Create a new project with Rails. rails new your-project-name --database=sqlite3 And cd into it. The database is optional, you can add it later.

  3. Install. bundle install

  4. If you added a database, create it. bin/rails db:create

  5. Install Hotwire bin/rails hotwire:install

  6. Create some pages, I'll create home, about, posts and contact. bin/rails generate controller Pages home about posts contact bin/rails This can be changed later.

  7. Run it bin/rails server

  8. Now you can edit your pages in app/views/pages/.... These are ruby files, you should write Ruby and HTML in here. Don't write CSS or JS in here.

CSS: To change global styles, edit app/assets/stylesheets/application.css. To change the style for a specific page, create and edit app/assets/stylesheets/pages/pagename.css e.g. home.css.

JS: To write page-specific scripts, edit app/controllers/pagename_controller.js e.g. home_controller.js, then attach it in your page's .erb file like this:

<div data-controller="home">
  ...
</div>

Notes

The app will automatically reload when you make changes.