{"action":"created","issue":{"url":"https://api.github.com/repos/rails/rails/issues/22424","labels_url":"https://api.github.com/repos/rails/rails/issues/22424/labels{/name}","comments_url":"https://api.github.com/repos/rails/rails/issues/22424/comments","events_url":"https://api.github.com/repos/rails/rails/issues/22424/events","html_url":"https://github.com/rails/rails/issues/22424","id":119143420,"number":22424,"title":"Decimal: Check attribute has value (with attrname?)","user":{"login":"Sega100500","id":584144,"avatar_url":"https://avatars.githubusercontent.com/u/584144?v=3","gravatar_id":"","url":"https://api.github.com/users/Sega100500","html_url":"https://github.com/Sega100500","followers_url":"https://api.github.com/users/Sega100500/followers","following_url":"https://api.github.com/users/Sega100500/following{/other_user}","gists_url":"https://api.github.com/users/Sega100500/gists{/gist_id}","starred_url":"https://api.github.com/users/Sega100500/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sega100500/subscriptions","organizations_url":"https://api.github.com/users/Sega100500/orgs","repos_url":"https://api.github.com/users/Sega100500/repos","events_url":"https://api.github.com/users/Sega100500/events{/privacy}","received_events_url":"https://api.github.com/users/Sega100500/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":16,"created_at":"2015-11-27T07:09:12Z","updated_at":"2015-11-27T16:31:44Z","closed_at":null,"body":"I use RoR 4.2.5\r\n\r\nin migration:\r\n```\r\nt.decimal :price, precision: 12, scale: 2\r\n```\r\n\r\nConvenient to use `@value.price?` to check for the value of any. Check for is not nil and not zero.\r\n\r\n```\r\n@value.price = nil\r\n@value.price? #=> false\r\n\r\n@value.price = 0\r\n@value.price? #=> false\r\n```\r\n\r\nAll Ok!\r\n\r\nBut!\r\n```\r\n@value.price = 0.01\r\n@value.price? #=> false\r\n\r\n@value.price = 0.9\r\n@value.price? #=> false\r\n\r\n@value.price = -0.9\r\n@value.price? #=> false\r\n\r\n@value.price = 1.0\r\n@value.price? #=> true\r\n\r\n@value.price = -1.0\r\n@value.price? #=> true\r\n```\r\n\r\nWHY?"},"comment":{"url":"https://api.github.com/repos/rails/rails/issues/comments/160171122","html_url":"https://github.com/rails/rails/issues/22424#issuecomment-160171122","issue_url":"https://api.github.com/repos/rails/rails/issues/22424","id":160171122,"user":{"login":"Sega100500","id":584144,"avatar_url":"https://avatars.githubusercontent.com/u/584144?v=3","gravatar_id":"","url":"https://api.github.com/users/Sega100500","html_url":"https://github.com/Sega100500","followers_url":"https://api.github.com/users/Sega100500/followers","following_url":"https://api.github.com/users/Sega100500/following{/other_user}","gists_url":"https://api.github.com/users/Sega100500/gists{/gist_id}","starred_url":"https://api.github.com/users/Sega100500/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sega100500/subscriptions","organizations_url":"https://api.github.com/users/Sega100500/orgs","repos_url":"https://api.github.com/users/Sega100500/repos","events_url":"https://api.github.com/users/Sega100500/events{/privacy}","received_events_url":"https://api.github.com/users/Sega100500/received_events","type":"User","site_admin":false},"created_at":"2015-11-27T16:31:44Z","updated_at":"2015-11-27T16:31:44Z","body":"@anujaware \r\n\"I am not getting why you are not getting that column in column_hash\"\r\n\r\nBecause this SQL:\r\n```\r\nSELECT products.*, contents.*, products.id AS product_id FROM `contents` INNER JOIN products ON products.content_id = contents.id WHERE (contents.visible != 0) AND `contents`.`visible` = 1 AND `contents`.`furl` = 'apple-iphone-5s-16gb' AND `products`.`id` = 191 AND `products`.`category_id` = 312 GROUP BY contents.id\r\n```\r\nto get with related content-page\r\n\r\n```\r\n>> @product.class.columns_hash.keys\r\n=> [\"id\", \"parent_id\", \"level\", \"position\", \"node_type\", \"user_id\", \"group_id\", \"restrictive_group_id\", \"visible\", \"system\", \"list\", \"no_children\", \"no_images\", \"no_files\", \"key_lock\", \"key\", \"url\", \"furl\", \"alias\", \"name\", \"brief\", \"text\", \"title\", \"seo\", \"keywords\", \"description\", \"special\", \"content_parameter\", \"content_date\", \"created_at\", \"updated_at\"]\r\n```\r\n\r\n```\r\n>> @product.price = 0.9\r\n=> 0.9\r\n>> @product[:price]\r\n=> 0.9\r\n```\r\n\r\nIt is VALID COE! But you have not considered this possibility.\r\ncolumns_hash NOT contain joined columns but access to they - it possible!\r\n\r\n\r\n\r\n\r\n"}}