Bug in tutorial: syntax error, unexpected ':', expecting keyword_end

后端 未结 2 992
轻奢々
轻奢々 2021-01-04 19:33

I am sorry for asking what may be a remedial question, but in learning rails i was trying to follow along note for note in this tutorial:

http://guides.rubyonrails.

相关标签:
2条回答
  • 2021-01-04 20:18

    i'm new to the ruby world i have started learning it this afternoon :)

    i had the same error as yours and i solved it by changing the way routes have been written to the suggested style within the routes.rb file.

    instead of what have been written on that tutorials copy and past this into your routes.rb

    Blog::Application.routes.draw do
      get "welcome/index"
     resources :posts
       root 'welcome#index'
      get    '/posts/:id(.:format)'  =>   'posts#show'
     get    '/posts(.:format)'       =>   'posts#index'
    end
    

    save and check your posts url as suggested on that tutorials

    http://localhost:3000/posts
    

    it should work for you.

    0 讨论(0)
  • 2021-01-04 20:31

    That line in section 5.7 is just showing you the output of rake routes, it's not meant to be in your config/routes.rb file.

    The line resources :posts in routes.rb generates the show posts route for you, test it by removing the line: post GET /posts/:id(.:format) posts#show and then running rake routes on the command line.

    0 讨论(0)
提交回复
热议问题