Reputation: 840
I'm new to Linux/Ruby/Rails, so I'm trying to learn by doing the Getting Started with Rails tutorial. In section 5.7, it doesn't specifically say what to do with this line:
post GET /posts/:id(.:format) posts#show
I assume I am to put this in the routes.rb file? I did, but then I get this when I try to GET any of the controller actions:
SyntaxError
/.../blog/config/routes.rb:9: syntax error, unexpected ':', expecting keyword_end post GET /posts/:id(.:format) posts#show ^
Being such a newbie, I have no idea what I should do at this point. What is the error on this line?
Thanks, James
Upvotes: 1
Views: 52
Reputation: 38645
You do not put the following in the config/routes.rb
file.
post GET /posts/:id(.:format) posts#show
This is the result of a route entry, which is what you'd put in your routes.rb
file. E.g.
get 'posts/:id', to: "posts#show"
Here get
is the HTTP method, posts/:id
is the path pattern, and the to: "posts#show"
is the name of the controller and action. So, when this pattern is encountered, Rails is going to execute show
action in PostsController
.
Recommend a read on "Rails Routing from the Outside In".
Upvotes: 2