Ruby on Rails workshops with ACM

Θέλεις να μάθεις μία νέα γλώσσα προγραμματισμού και να εμπλουτίσεις τις γνώσεις σου; Η Ruby είμαι μία δυναμική open source γλώσσα που βρίσκει εφαρμογή στο διαδίκτυο. Έλα και εσύ να τη γνωρίσεις και να δημιουργήσεις την πρώτη σου εφαρμογή! Φέρε το λάπτοπ σου! 💻🔧

When;Where;
13/12/2019, 16:16ΔΙΠΑΕ Θεσσαλονίκης

Cheatsheet

Model - Represents the entities of the application and is directly connected to the databaseView - View files hold the HTML code that creates the content we serve on the browserController - Glues everything together, calls the model, performs actions on the entities, redirects appropriately
CRUD - Default actions - Create Read Update DestroyDRY - Don't Repeat Yourself
rails server - start the rails server to serve your applicationrails console - Fire up the rails console and try rails stuff!

MVC

Model - Represents the entities of the application and is directly connected to the databaseView - View files hold the HTML code that creates the content we serve on the browserController - Glues everything together, calls the model, performs actions on the entities, redirects appropriately

Key Concepts

CRUD - Default actions - Create Read Update DestroyDRY - Don't Repeat Yourself

Get started!

rails server - start the rails server to serve your applicationrails console - Fire up the rails console and try rails stuff!

Useful links

Code Snippets

Basics

# Serve your application
rails server
# Use rails console
rails console
# Create a new entity (all MVC structure)
rails g scaffold User name:string address:text
# Apply changes to database
rails db:migrate
# Add new gemsAdd gem names in Gemfile and run
bundle install
Bash

New Rails Application

# Create a new rails project
rails new learning -T
cd learning
# Optionally use HAML
# Add the following line inside file Gemfile
gem 'haml-rails'
# Add RSPEC for testing
gem 'rspec'
# Apply the changes of Gemfile
bundle install
# Start the rails server
rails s 
Bash

Add Entity

# Create a new rails project
rails g scaffold Course name:string description:text semester:integer
# Add new attribute color to Course model
rails g migration AddColorToCourses color:string
# Apply changes to database
rails db:migrate 
Bash