{"action":"created","issue":{"url":"https://api.github.com/repos/amberframework/amber/issues/339","repository_url":"https://api.github.com/repos/amberframework/amber","labels_url":"https://api.github.com/repos/amberframework/amber/issues/339/labels{/name}","comments_url":"https://api.github.com/repos/amberframework/amber/issues/339/comments","events_url":"https://api.github.com/repos/amberframework/amber/issues/339/events","html_url":"https://github.com/amberframework/amber/issues/339","id":269422665,"number":339,"title":"Scaffold generated code gives a CSRF error on delete","user":{"login":"satb","id":2095367,"avatar_url":"https://avatars1.githubusercontent.com/u/2095367?v=4","gravatar_id":"","url":"https://api.github.com/users/satb","html_url":"https://github.com/satb","followers_url":"https://api.github.com/users/satb/followers","following_url":"https://api.github.com/users/satb/following{/other_user}","gists_url":"https://api.github.com/users/satb/gists{/gist_id}","starred_url":"https://api.github.com/users/satb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/satb/subscriptions","organizations_url":"https://api.github.com/users/satb/orgs","repos_url":"https://api.github.com/users/satb/repos","events_url":"https://api.github.com/users/satb/events{/privacy}","received_events_url":"https://api.github.com/users/satb/received_events","type":"User","site_admin":false},"labels":[{"id":585735836,"url":"https://api.github.com/repos/amberframework/amber/labels/bug","name":"bug","color":"ee0701","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":23,"created_at":"2017-10-29T18:30:26Z","updated_at":"2017-11-01T23:52:44Z","closed_at":null,"author_association":"NONE","body":"<!--\r\nHave you read Amber's Code of Conduct? By filing an Issue, you are expected to comply with it, including treating everyone with respect: https://github.com/amberframework/amber/blob/master/.github/CODE_OF_CONDUCT.md\r\nDo you want to ask a question? Are you looking for support? The Amber message board is the best place for getting support: https://gitter.io/amberframework/amber\r\n-->\r\n\r\n### Description\r\n\r\nVery new to Crystal and Amber. Was going through the guides and generated a basic project with one User model. The app started and everything was good but \"delete\" of the user isn't working. It fails with a \"CSRF check failed.\" error upon delete.\r\n\r\nAlso delete musn't be a http get request but a http post. The network request on delete is a GET with out of the box scaffolding and the URL looks like this - \"http://localhost:3000/users/1?_method=delete\"\r\n\r\n### Steps to Reproduce\r\n\r\n1. amber new myapp\r\n2. amber g scaffold User first_name:string last_name:string\r\n3. shards install (took me a while to figure out why amber was complaining that \"require \"amber\"\" is failing. Looks like crystal shards now install to a local lib folder\r\n4. amber w\r\n5. open http://localhost:3000\r\n6. Create a new user and try to delete the user\r\n\r\n**Expected behavior:** http post request with _method of delete and no CSRF error\r\n\r\n**Actual behavior:** http get request with an error that says \"CSRF check failed.\"\r\n\r\n**Reproduces how often:** Everytime\r\n\r\n### Versions\r\n\r\n❯ amber --version\r\nAmber CMD (amberframework.org) - v0.3.0\r\n\r\n### Additional Information\r\n\r\nJust an out of the box scaffolding"},"comment":{"url":"https://api.github.com/repos/amberframework/amber/issues/comments/341277465","html_url":"https://github.com/amberframework/amber/issues/339#issuecomment-341277465","issue_url":"https://api.github.com/repos/amberframework/amber/issues/339","id":341277465,"user":{"login":"elorest","id":124580,"avatar_url":"https://avatars3.githubusercontent.com/u/124580?v=4","gravatar_id":"","url":"https://api.github.com/users/elorest","html_url":"https://github.com/elorest","followers_url":"https://api.github.com/users/elorest/followers","following_url":"https://api.github.com/users/elorest/following{/other_user}","gists_url":"https://api.github.com/users/elorest/gists{/gist_id}","starred_url":"https://api.github.com/users/elorest/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elorest/subscriptions","organizations_url":"https://api.github.com/users/elorest/orgs","repos_url":"https://api.github.com/users/elorest/repos","events_url":"https://api.github.com/users/elorest/events{/privacy}","received_events_url":"https://api.github.com/users/elorest/received_events","type":"User","site_admin":false},"created_at":"2017-11-01T23:52:44Z","updated_at":"2017-11-01T23:52:44Z","author_association":"CONTRIBUTOR","body":"Should we just opt for a simple fix for now? And add some helpers later? My vote would be to add csrf to the link for now and work on some helpers later. What's important is that generated code works and is secure. We can acheive this vis `link_to \"delete\", \"/listing/1?_method=DELETE&csrf=#{CSRF.token}\"`"}}
{"actor":{"display_login":"elorest"}}