- About me
- Korey MacDougall
- Researcher and Developer
- New to Sudbury
- Founder of Nickel City Software Inc.
- Lover of GNU/Linux, FLOSS, and vim
- Have been working with rails for approx 2.5 yrs
- Today we will try to cover:
- Tools/software needed to develop a rails app
- Basics of Rails philosophy and architectural pattern (MVC)
- How to create a simple rails app: an RPG character creator
- all code is at notabug.org/kmac
- running app looks like this...
- virtualbox.org/wiki/Downloads
- guest additions
- sudo apt-get install ruby-dev
- chruby
- rbenv
- rvm
- Linux: sudo apt-get install nodejs
- windows: https://nodejs.org/en/download/
- macOS: brew install node
- bundler.io
- a 'gem' is a ruby package
- sudo gem install bundler
- or try (windows): gem install bundler
- sqlite for development
- sudo apt-get install libsqlite3-dev
- sudo gem install rails
- atom
- https://flight-manual.atom.io/getting-started/sections/installing-atom/
- lots of different technologies involved, mainly html/css/js & ruby
- we will only touch a small sub-section of it today
- front-end frameworks (CSS & JS)
- asynchronous jobs
- cloud deployments
- databases
- Model: object properties and methods
- View: what is displayed to user
- Controller: handles request routing
- Many 'sane defaults' that save developers from writing repetitive code
rails new char_maker
cd char_maker
rails server
In browser: visit localhost:3000
- we will mostly be working within app/ and config/
rails generate scaffold Character name:string health:integer strength:integer intelligence:integer agility:integer luck:integer
refresh page, see error
These characters are CRUD objects
Notice the routes
active_storage:install
db:migrate
config/storage.yml, only keep local
edit config/environments/development.rb
Attach files to records
edit app/views/characters/_form.html.erb
Allow avatar parameter through
Display avatar on index page
Display avatar on character page, app/views/characters/show.html.erb
<%= image_tag(@character.avatar, size: '250x250') %>
Modify Gemfile
bundle install
restart server
rename application.css, b/c bootstrap uses scss
edit app/assets/stylesheets/application.scss
add bootstrap dependencies to app/asssets/javascripts/application.js //= require jquery3 //= require popper //= require bootstrap-sprockets
Add table styling to index page
Change page title
Change "New" link_to to a button:
Pad/center table
add to app/assets/stylesheets/characters.scss:
add to app/assets/stylesheets/application.scss:
Center New Char screen
Add a page background
Could style the new char screen as a table