Beginners question - can't find the reason for an error


I have a line of code that is copied from the tutorial:

<%= link_to 'Delete', post_path(@post), method :delete, data: { confirm: 'Are you sure?' } %>

And it causes syntax error, unexpected tSYMBEG, expecting keyword_do or '{' or '(' ...te', post_path(@post), method :delete, data: { confirm: 'Are... ... ^

If I remove method :delete , the page loads with no errors.

Here is my rake routes:
Prefix Verb URI Pattern Controller#Action
root GET / posts#index
posts GET /posts(.:format) posts#index
POST /posts(.:format) posts#create
new_post GET /posts/new(.:format) posts#new
edit_post GET /posts/:id/edit(.:format) posts#edit
post GET /posts/:id(.:format) posts#show
PATCH /posts/:id(.:format) posts#update
PUT /posts/:id(.:format) posts#update
DELETE /posts/:id(.:format) posts#destroy

I’m very confused since this is the same line as in tutorials and it works fine there. Tried google with no luck.

I would appreciate if someone could explain why this is happening.

Copy and paste the next line

<%= link_to 'Delete', post_path(@post), method: :delete, data: { confirm: 'Are you sure?' } %>

your mistake is that it is not

method :delete


method: :delete

oh thank you, how could I missed that.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs