[熱情]

ruby on rails - start 본문

카테고리 없음

ruby on rails - start

rootkaien 2017. 2. 10. 11:08



Mac에서 Ruby 설치하기.


- 기본적을 ruby 2.0설치 되어 있다.

- 생활코딩 저보 활용. :   https://opentutorials.org/course/1750/9611

-

  1. 터미널을 실행합니다.
  2. ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  3. brew update
  4. brew install ruby
  5. nano ~/.bash_profile 실행 후 아래 코드 삽입 후 저장
    export PATH=$(brew --prefix ruby)/bin:$PATH
  6. 터미널을 다시 실행하고 ruby -v를 실행한 결과가 2 이상이면 성공 


- 루비 버전 확인

$ ruby -v


- 대화형 루비셸(irb)

$ irb

irb(main):001:0>




http://guides.rubyonrails.org/getting_started.html



what is rails.. ?

- Rails is a web application development framework written in the Ruby.


(sqlite3 설치 확임)

$ sqlite3 --version


Rails 설치

$ gem install rails

$ rails --version


Creating the Blog Application

- 대략 모든 사이트에서 시작은 blog로 하더라. ㅎㅎ


$ rails new blog


- 설치되는때까지 시간이 조금 걸림.


$ cd blog



File/FolderPurpose
app/Contains the controllers, models, views, helpers, mailers and assets for your application. You'll focus on this folder for the remainder of this guide.
bin/Contains the rails script that starts your app and can contain other scripts you use to setup, update, deploy or run your application.
config/Configure your application's routes, database, and more. This is covered in more detail in Configuring Rails Applications.
config.ruRack configuration for Rack based servers used to start the application.
db/Contains your current database schema, as well as the database migrations.
Gemfile
Gemfile.lock
These files allow you to specify what gem dependencies are needed for your Rails application. These files are used by the Bundler gem. For more information about Bundler, see the Bundler website.
lib/Extended modules for your application.
log/Application log files.
public/The only folder seen by the world as-is. Contains static files and compiled assets.
RakefileThis file locates and loads tasks that can be run from the command line. The task definitions are defined throughout the components of Rails. Rather than changing Rakefile, you should add your own tasks by adding files to the lib/tasks directory of your application.
README.mdThis is a brief instruction manual for your application. You should edit this file to tell others what your application does, how to set it up, and so on.
test/Unit tests, fixtures, and other test apparatus. These are covered in Testing Rails Applications.
tmp/Temporary files (like cache and pid files).
vendor/A place for all third-party code. In a typical Rails application this includes vendored gems.

Starting up the Web Server


$ bin/rails server


http://localhost:3000



$ bin/rails generate controller Welcome index


create  app/controllers/welcome_controller.rb
 route  get 'welcome/index'
invoke  erb
create    app/views/welcome
create    app/views/welcome/index.html.erb
invoke  test_unit
create    test/controllers/welcome_controller_test.rb
invoke  helper
create    app/helpers/welcome_helper.rb
invoke  assets
invoke    coffee
create      app/assets/javascripts/welcome.coffee
invoke    scss
create      app/assets/stylesheets/welcome.scss


eidt : app/views/welcome/index.html.erb


<h1>Hello, Rails!</h1>




























Comments