아래와 같이 컨트롤 생성하고 함수도 만들었으니
controll명과 method명을 넣어서 화면을 보면 Hellow world라는 화면이 떠야 할텐데....


1. 내가 한 작업
D:\Code\blog>rails g controller stat
      create  app/controllers/stat_controller.rb
      invoke  erb
      create    app/views/stat
      invoke  test_unit
      create    test/functional/stat_controller_test.rb
      invoke  helper
      create    app/helpers/stat_helper.rb
      invoke    test_unit
      create      test/unit/helpers/stat_helper_test.rb
      invoke  assets
      invoke    coffee
      create      app/assets/javascripts/stat.js.coffee
      invoke    scss
      create      app/assets/stylesheets/stat.css.scss

 


2. 접속해보면?
아래와 같이 Routing Error가 뜬다.
http://127.0.0.1:3000/stat/index

절망.... 인터넷을 뒤져보면
routers.rb파일에 아래 내용을 추가하면 된다는데 역시 안된다.
map.connect '*url', :action => 'show_page'




[해결법]
routes.rb 파일에 아래와 같이 내용을 추가해주니 (접속할 주소와 연관된것이니 적당히 맞춰서 등록할것)

...
get "stat/index"
...



http://127.0.0.1:3000/stat/index
아래와 같이 결과가 뿅~





 

+ Recent posts