1

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

1 Answer 1

2

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".

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.