-
Stwórz konto na
https://codeanywhere.com
https://codenvy.io
-
Instalujemy railsy
gem install rails -v 5.0.0
-
“hello, world” program (create a skeleton Rails application)
cd # Change to the home directory.
mkdir workspace # Make a workspace directory.
cd workspace/ # Change into the workspace directory.
-
rails new hello_app
-
Gemfile
-
source 'https://rubygems.org'
gem 'rails', '5.1.4'
gem 'puma', '3.9.1'
gem 'sass-rails', '5.0.6'
gem 'uglifier', '3.2.0'
gem 'coffee-rails', '4.2.2'
gem 'jquery-rails', '4.3.1'
gem 'turbolinks', '5.0.1'
gem 'jbuilder', '2.7.0'
group :development, :test do
gem 'rb-readline'
gem 'sqlite3', '1.3.13'
gem 'byebug', '9.0.6', platform: :mri
end
group :development do
gem 'web-console', '3.5.1'
gem 'listen', '3.1.5'
gem 'spring', '2.0.2'
gem 'spring-watcher-listen', '2.0.1'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
-
cd hello_app/
gem install bundler
bundle config --delete without
bundle config --delete with
bundle install
-
rails server -b 0.0.0.0
-
On a local server, paste the URL http://0.0.0.0:3000 ;
On the cloud IDE, go to Share and click on the Application address to open it
-
Directory called app/ containing three subdirectories: models, views, and
controllers.
When interacting with a Rails application, a browser sends a request that is received by a
webserver and passed on to a Rails controller, which is in charge of what to do next. In some cases,
the controller will immediately render a view, which is a template that gets converted to HTML and
sent back to the browser. More commonly for dynamic sites, the controller interacts with a model,
which is a Ruby object that represents an element of the site (such as a user) and is in charge of
communicating with the database. After invoking the model, the controller then renders the view and
returns the complete web page to the browser as HTML.
-
Render the string “hello, world!” to replace the default Rails page
Add a hello action to the Application controller.
app/controllers/application_controller.rb
def hello
render html: "hello, world!"
end
- Add to
config/routes.rb
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root 'application#hello'
end
-
Version Control with Git
git config --global user.name "Your Name"
git config --global user.email your.email@example.com
git init
git add -A
-
The rails new command automatically generates a .gitignore file appropriate to a Rails project
git status
-
The -m flag lets us add a message for the commit;
git commit -m "Initialize repository"
-
Bitbucket
It is important to note that Git commits are local, recorded only on the machine on which the
commits occur.
-
Copy your public key
cat .ssh/id_rsa.pub
-
Add your public key to Bitbucket by clicking on the avatar image in the upper right and selecting “Settings ” and then “SSH keys”
-
Create a new repository
git remote add origin git@bitbucket.org:przem85/hello_app.git
git add ,
git commit -m "initial commit"
git push -u origin --all
lub
git push origin master
-
$ git checkout -b modify-README
git branch
-
Add to README.md
# README
# Ruby on Rails Tutorial
## "hello, world!"
This is the first application.
-
git add -A
git commit -a -m "Improve the README file"
-
git checkout master
git merge modify-README
-
-->