{"action":"created","issue":{"url":"https://api.github.com/repos/lebedev-yury/carrierwave-base64/issues/23","labels_url":"https://api.github.com/repos/lebedev-yury/carrierwave-base64/issues/23/labels{/name}","comments_url":"https://api.github.com/repos/lebedev-yury/carrierwave-base64/issues/23/comments","events_url":"https://api.github.com/repos/lebedev-yury/carrierwave-base64/issues/23/events","html_url":"https://github.com/lebedev-yury/carrierwave-base64/issues/23","id":112170699,"number":23,"title":"Element is always marked as changed, also if it's not","user":{"login":"jmuheim","id":1814983,"avatar_url":"https://avatars.githubusercontent.com/u/1814983?v=3","gravatar_id":"","url":"https://api.github.com/users/jmuheim","html_url":"https://github.com/jmuheim","followers_url":"https://api.github.com/users/jmuheim/followers","following_url":"https://api.github.com/users/jmuheim/following{/other_user}","gists_url":"https://api.github.com/users/jmuheim/gists{/gist_id}","starred_url":"https://api.github.com/users/jmuheim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmuheim/subscriptions","organizations_url":"https://api.github.com/users/jmuheim/orgs","repos_url":"https://api.github.com/users/jmuheim/repos","events_url":"https://api.github.com/users/jmuheim/events{/privacy}","received_events_url":"https://api.github.com/users/jmuheim/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-10-19T15:34:49Z","updated_at":"2015-10-23T06:01:42Z","closed_at":null,"body":"I just noticed that an element that has a `mount_base64_uploader` mounted is always marked as changed and thus saved to the DB, even when it's not changed.\r\n\r\nIt's a bit hard to describe, but let's try this.\r\n\r\nI have a `User` model like this:\r\n\r\n```ruby\r\nclass User < ActiveRecord::Base\r\n  mount_base64_uploader :file_upload,   ImageUploader\r\n  mount_base64_uploader :string_upload, ImageUploader\r\nend\r\n```\r\n\r\nWhen I edit it in a form and **don't** change a thing, then the following DB query is executed anyways due to the log file:\r\n\r\n```\r\n  SQL (0.3ms)  UPDATE \"users\" SET \"string_upload\" = ?, \"updated_at\" = ? WHERE \"users\".\"id\" = ?  [[\"string_upload\", \"file.png\"], [\"updated_at\", \"2015-10-19 15:27:10.106767\"], [\"id\", 10]]\r\n```\r\n\r\nHere are the `user_params`:\r\n\r\n```\r\n$ user_params\r\n=> {\"name\"=>\"2haha\",\r\n \"file_upload_cache\"=>\"\",\r\n \"remove_file_upload\"=>\"0\",\r\n \"string_upload\"=>\"file.png\",\r\n \"string_upload_cache\"=>\"\",\r\n \"remove_string_upload\"=>\"0\"\r\n}\r\n```\r\n\r\nNotice: only the `:string_upload` field is written to DB, not the `:file_upload`, so I guess it's a problem in your gem. I think you have to check whether the sent param is only `file.png` and then you **don't** mark the attribute as changed.\r\n\r\nWhile this may not be a big issue, it breaks some custom functionality of my app that relies on the fact that resources announce their changed status correctly.\r\n\r\nYou can still checkout my demo app here to see the problematic behaviour: https://github.com/jmuheim/test-carrierwave-base64-update"},"comment":{"url":"https://api.github.com/repos/lebedev-yury/carrierwave-base64/issues/comments/150484700","html_url":"https://github.com/lebedev-yury/carrierwave-base64/issues/23#issuecomment-150484700","issue_url":"https://api.github.com/repos/lebedev-yury/carrierwave-base64/issues/23","id":150484700,"user":{"login":"jmuheim","id":1814983,"avatar_url":"https://avatars.githubusercontent.com/u/1814983?v=3","gravatar_id":"","url":"https://api.github.com/users/jmuheim","html_url":"https://github.com/jmuheim","followers_url":"https://api.github.com/users/jmuheim/followers","following_url":"https://api.github.com/users/jmuheim/following{/other_user}","gists_url":"https://api.github.com/users/jmuheim/gists{/gist_id}","starred_url":"https://api.github.com/users/jmuheim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmuheim/subscriptions","organizations_url":"https://api.github.com/users/jmuheim/orgs","repos_url":"https://api.github.com/users/jmuheim/repos","events_url":"https://api.github.com/users/jmuheim/events{/privacy}","received_events_url":"https://api.github.com/users/jmuheim/received_events","type":"User","site_admin":false},"created_at":"2015-10-23T06:01:42Z","updated_at":"2015-10-23T06:01:42Z","body":"Thanks for helping. I will take another look at my app next week and provide you with details, if necessary.\r\n\r\nHave a nice weekend! :)"}}