Skip to content

Rails:Route

List of route

아래의 명령으로 Route목록을 확인할 수 있다.

$ rake routes

root method

Route시 아래와 같은 코드가 사용된다.

root to: 'home#index'

이 것은 Base모듈의 root함수를 Mixin으로 사용하는 것이다. 참고로 아래는 해당 코드의 내용이다. 1

module Base
    # ...
    def root(options = {})
        match '/', { :as => :root, :via => :get }.merge!(options)
    end
    # ...
end

따라서 문법적으로 다시 적는다면 아래와 상통한다 할 수 있다.

root({to: 'home#index'})

참고로 to:의 경우 Symbol을 사용하는 것이다.

See also

References


  1. MAC OSX 기준으로 /Library/Ruby/Gems/2.0.0/gems/actionpack-4.2.5/lib/action_dispatch/routing/mapper.rb에 존재한다.