{"action":"closed","number":1398,"pull_request":{"url":"https://api.github.com/repos/plataformatec/simple_form/pulls/1398","id":76042011,"html_url":"https://github.com/plataformatec/simple_form/pull/1398","diff_url":"https://github.com/plataformatec/simple_form/pull/1398.diff","patch_url":"https://github.com/plataformatec/simple_form/pull/1398.patch","issue_url":"https://api.github.com/repos/plataformatec/simple_form/issues/1398","number":1398,"state":"closed","locked":false,"title":"Use Rails 5 Attributes API for decimal_or_float?","user":{"login":"olivierlacan","id":65950,"avatar_url":"https://avatars.githubusercontent.com/u/65950?v=3","gravatar_id":"","url":"https://api.github.com/users/olivierlacan","html_url":"https://github.com/olivierlacan","followers_url":"https://api.github.com/users/olivierlacan/followers","following_url":"https://api.github.com/users/olivierlacan/following{/other_user}","gists_url":"https://api.github.com/users/olivierlacan/gists{/gist_id}","starred_url":"https://api.github.com/users/olivierlacan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olivierlacan/subscriptions","organizations_url":"https://api.github.com/users/olivierlacan/orgs","repos_url":"https://api.github.com/users/olivierlacan/repos","events_url":"https://api.github.com/users/olivierlacan/events{/privacy}","received_events_url":"https://api.github.com/users/olivierlacan/received_events","type":"User","site_admin":false},"body":"The motivation for this commit originated in #1342.\r\n\r\n@rafaelfranca mentioned that we should be using the new `type_for_attribute` interface\r\nto determine the precise type of a column instead. At first I used the interface directly like\r\nthis:\r\n\r\n```ruby\r\n      def decimal_or_float?\r\n        if object.respond_to?(:type_for_attribute)\r\n          type = object.type_for_attribute(column.name.to_s).type\r\n          type == :float || :decimal\r\n        else\r\n          column.number? && column.type != :integer\r\n        end\r\n      end\r\n```\r\n\r\nI then realized that we're already asking the column object directly for the type, so\r\nwhy not simple check for the two types we care about and implement the method in a much\r\nmore straightforward *and* backward-compatible way? I ended up with this:\r\n\r\n```ruby\r\n      def decimal_or_float?\r\n        column.type == :float || :decimal\r\n      end\r\n```\r\n\r\nI could be missing something obvious but this is green in my Rails 5.0.0 app. The only\r\nremaining issue I see is how the simple_form specs mock out the now removed number?\r\nActiveModel method: https://github.com/plataformatec/simple_form/blob/1c389f65594db90a1244d93a00a388b4aea4bcc6/test/support/models.rb#L3-L8\r\n\r\nI'm gonna have to remove that most likely.\r\n\r\n/cc @lucasmazza ","created_at":"2016-07-01T22:02:18Z","updated_at":"2016-08-25T17:14:37Z","closed_at":"2016-08-25T17:14:37Z","merged_at":null,"merge_commit_sha":"764c80805f8b892cd26fdfa993c7b19eb3b71c11","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/plataformatec/simple_form/pulls/1398/commits","review_comments_url":"https://api.github.com/repos/plataformatec/simple_form/pulls/1398/comments","review_comment_url":"https://api.github.com/repos/plataformatec/simple_form/pulls/comments{/number}","comments_url":"https://api.github.com/repos/plataformatec/simple_form/issues/1398/comments","statuses_url":"https://api.github.com/repos/plataformatec/simple_form/statuses/86ab4252ecad1956fa2ddeea2d62a1584dac10f6","head":{"label":"olivierlacan:rails-5-type-for-attribute","ref":"rails-5-type-for-attribute","sha":"86ab4252ecad1956fa2ddeea2d62a1584dac10f6","user":{"login":"olivierlacan","id":65950,"avatar_url":"https://avatars.githubusercontent.com/u/65950?v=3","gravatar_id":"","url":"https://api.github.com/users/olivierlacan","html_url":"https://github.com/olivierlacan","followers_url":"https://api.github.com/users/olivierlacan/followers","following_url":"https://api.github.com/users/olivierlacan/following{/other_user}","gists_url":"https://api.github.com/users/olivierlacan/gists{/gist_id}","starred_url":"https://api.github.com/users/olivierlacan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olivierlacan/subscriptions","organizations_url":"https://api.github.com/users/olivierlacan/orgs","repos_url":"https://api.github.com/users/olivierlacan/repos","events_url":"https://api.github.com/users/olivierlacan/events{/privacy}","received_events_url":"https://api.github.com/users/olivierlacan/received_events","type":"User","site_admin":false},"repo":{"id":2446342,"name":"simple_form","full_name":"olivierlacan/simple_form","owner":{"login":"olivierlacan","id":65950,"avatar_url":"https://avatars.githubusercontent.com/u/65950?v=3","gravatar_id":"","url":"https://api.github.com/users/olivierlacan","html_url":"https://github.com/olivierlacan","followers_url":"https://api.github.com/users/olivierlacan/followers","following_url":"https://api.github.com/users/olivierlacan/following{/other_user}","gists_url":"https://api.github.com/users/olivierlacan/gists{/gist_id}","starred_url":"https://api.github.com/users/olivierlacan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olivierlacan/subscriptions","organizations_url":"https://api.github.com/users/olivierlacan/orgs","repos_url":"https://api.github.com/users/olivierlacan/repos","events_url":"https://api.github.com/users/olivierlacan/events{/privacy}","received_events_url":"https://api.github.com/users/olivierlacan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/olivierlacan/simple_form","description":"Forms made easy for Rails! It's tied to a simple DSL, with no opinion on markup.","fork":true,"url":"https://api.github.com/repos/olivierlacan/simple_form","forks_url":"https://api.github.com/repos/olivierlacan/simple_form/forks","keys_url":"https://api.github.com/repos/olivierlacan/simple_form/keys{/key_id}","collaborators_url":"https://api.github.com/repos/olivierlacan/simple_form/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/olivierlacan/simple_form/teams","hooks_url":"https://api.github.com/repos/olivierlacan/simple_form/hooks","issue_events_url":"https://api.github.com/repos/olivierlacan/simple_form/issues/events{/number}","events_url":"https://api.github.com/repos/olivierlacan/simple_form/events","assignees_url":"https://api.github.com/repos/olivierlacan/simple_form/assignees{/user}","branches_url":"https://api.github.com/repos/olivierlacan/simple_form/branches{/branch}","tags_url":"https://api.github.com/repos/olivierlacan/simple_form/tags","blobs_url":"https://api.github.com/repos/olivierlacan/simple_form/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/olivierlacan/simple_form/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/olivierlacan/simple_form/git/refs{/sha}","trees_url":"https://api.github.com/repos/olivierlacan/simple_form/git/trees{/sha}","statuses_url":"https://api.github.com/repos/olivierlacan/simple_form/statuses/{sha}","languages_url":"https://api.github.com/repos/olivierlacan/simple_form/languages","stargazers_url":"https://api.github.com/repos/olivierlacan/simple_form/stargazers","contributors_url":"https://api.github.com/repos/olivierlacan/simple_form/contributors","subscribers_url":"https://api.github.com/repos/olivierlacan/simple_form/subscribers","subscription_url":"https://api.github.com/repos/olivierlacan/simple_form/subscription","commits_url":"https://api.github.com/repos/olivierlacan/simple_form/commits{/sha}","git_commits_url":"https://api.github.com/repos/olivierlacan/simple_form/git/commits{/sha}","comments_url":"https://api.github.com/repos/olivierlacan/simple_form/comments{/number}","issue_comment_url":"https://api.github.com/repos/olivierlacan/simple_form/issues/comments{/number}","contents_url":"https://api.github.com/repos/olivierlacan/simple_form/contents/{+path}","compare_url":"https://api.github.com/repos/olivierlacan/simple_form/compare/{base}...{head}","merges_url":"https://api.github.com/repos/olivierlacan/simple_form/merges","archive_url":"https://api.github.com/repos/olivierlacan/simple_form/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/olivierlacan/simple_form/downloads","issues_url":"https://api.github.com/repos/olivierlacan/simple_form/issues{/number}","pulls_url":"https://api.github.com/repos/olivierlacan/simple_form/pulls{/number}","milestones_url":"https://api.github.com/repos/olivierlacan/simple_form/milestones{/number}","notifications_url":"https://api.github.com/repos/olivierlacan/simple_form/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/olivierlacan/simple_form/labels{/name}","releases_url":"https://api.github.com/repos/olivierlacan/simple_form/releases{/id}","deployments_url":"https://api.github.com/repos/olivierlacan/simple_form/deployments","created_at":"2011-09-23T19:54:59Z","updated_at":"2013-01-04T07:23:18Z","pushed_at":"2016-07-26T12:47:56Z","git_url":"git://github.com/olivierlacan/simple_form.git","ssh_url":"git@github.com:olivierlacan/simple_form.git","clone_url":"https://github.com/olivierlacan/simple_form.git","svn_url":"https://github.com/olivierlacan/simple_form","homepage":"http://blog.plataformatec.com.br/tag/simple_form","size":3553,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"plataformatec:master","ref":"master","sha":"b440a6cfbfd02d898ba0cdaf4bb6e8cae7b879a9","user":{"login":"plataformatec","id":127679,"avatar_url":"https://avatars.githubusercontent.com/u/127679?v=3","gravatar_id":"","url":"https://api.github.com/users/plataformatec","html_url":"https://github.com/plataformatec","followers_url":"https://api.github.com/users/plataformatec/followers","following_url":"https://api.github.com/users/plataformatec/following{/other_user}","gists_url":"https://api.github.com/users/plataformatec/gists{/gist_id}","starred_url":"https://api.github.com/users/plataformatec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plataformatec/subscriptions","organizations_url":"https://api.github.com/users/plataformatec/orgs","repos_url":"https://api.github.com/users/plataformatec/repos","events_url":"https://api.github.com/users/plataformatec/events{/privacy}","received_events_url":"https://api.github.com/users/plataformatec/received_events","type":"Organization","site_admin":false},"repo":{"id":451035,"name":"simple_form","full_name":"plataformatec/simple_form","owner":{"login":"plataformatec","id":127679,"avatar_url":"https://avatars.githubusercontent.com/u/127679?v=3","gravatar_id":"","url":"https://api.github.com/users/plataformatec","html_url":"https://github.com/plataformatec","followers_url":"https://api.github.com/users/plataformatec/followers","following_url":"https://api.github.com/users/plataformatec/following{/other_user}","gists_url":"https://api.github.com/users/plataformatec/gists{/gist_id}","starred_url":"https://api.github.com/users/plataformatec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plataformatec/subscriptions","organizations_url":"https://api.github.com/users/plataformatec/orgs","repos_url":"https://api.github.com/users/plataformatec/repos","events_url":"https://api.github.com/users/plataformatec/events{/privacy}","received_events_url":"https://api.github.com/users/plataformatec/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/plataformatec/simple_form","description":"Forms made easy for Rails! It's tied to a simple DSL, with no opinion on markup.","fork":false,"url":"https://api.github.com/repos/plataformatec/simple_form","forks_url":"https://api.github.com/repos/plataformatec/simple_form/forks","keys_url":"https://api.github.com/repos/plataformatec/simple_form/keys{/key_id}","collaborators_url":"https://api.github.com/repos/plataformatec/simple_form/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/plataformatec/simple_form/teams","hooks_url":"https://api.github.com/repos/plataformatec/simple_form/hooks","issue_events_url":"https://api.github.com/repos/plataformatec/simple_form/issues/events{/number}","events_url":"https://api.github.com/repos/plataformatec/simple_form/events","assignees_url":"https://api.github.com/repos/plataformatec/simple_form/assignees{/user}","branches_url":"https://api.github.com/repos/plataformatec/simple_form/branches{/branch}","tags_url":"https://api.github.com/repos/plataformatec/simple_form/tags","blobs_url":"https://api.github.com/repos/plataformatec/simple_form/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/plataformatec/simple_form/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/plataformatec/simple_form/git/refs{/sha}","trees_url":"https://api.github.com/repos/plataformatec/simple_form/git/trees{/sha}","statuses_url":"https://api.github.com/repos/plataformatec/simple_form/statuses/{sha}","languages_url":"https://api.github.com/repos/plataformatec/simple_form/languages","stargazers_url":"https://api.github.com/repos/plataformatec/simple_form/stargazers","contributors_url":"https://api.github.com/repos/plataformatec/simple_form/contributors","subscribers_url":"https://api.github.com/repos/plataformatec/simple_form/subscribers","subscription_url":"https://api.github.com/repos/plataformatec/simple_form/subscription","commits_url":"https://api.github.com/repos/plataformatec/simple_form/commits{/sha}","git_commits_url":"https://api.github.com/repos/plataformatec/simple_form/git/commits{/sha}","comments_url":"https://api.github.com/repos/plataformatec/simple_form/comments{/number}","issue_comment_url":"https://api.github.com/repos/plataformatec/simple_form/issues/comments{/number}","contents_url":"https://api.github.com/repos/plataformatec/simple_form/contents/{+path}","compare_url":"https://api.github.com/repos/plataformatec/simple_form/compare/{base}...{head}","merges_url":"https://api.github.com/repos/plataformatec/simple_form/merges","archive_url":"https://api.github.com/repos/plataformatec/simple_form/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/plataformatec/simple_form/downloads","issues_url":"https://api.github.com/repos/plataformatec/simple_form/issues{/number}","pulls_url":"https://api.github.com/repos/plataformatec/simple_form/pulls{/number}","milestones_url":"https://api.github.com/repos/plataformatec/simple_form/milestones{/number}","notifications_url":"https://api.github.com/repos/plataformatec/simple_form/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/plataformatec/simple_form/labels{/name}","releases_url":"https://api.github.com/repos/plataformatec/simple_form/releases{/id}","deployments_url":"https://api.github.com/repos/plataformatec/simple_form/deployments","created_at":"2009-12-28T14:23:48Z","updated_at":"2016-08-25T07:14:51Z","pushed_at":"2016-08-25T17:12:40Z","git_url":"git://github.com/plataformatec/simple_form.git","ssh_url":"git@github.com:plataformatec/simple_form.git","clone_url":"https://github.com/plataformatec/simple_form.git","svn_url":"https://github.com/plataformatec/simple_form","homepage":"http://blog.plataformatec.com.br/tag/simple_form","size":3300,"stargazers_count":6233,"watchers_count":6233,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1010,"mirror_url":null,"open_issues_count":63,"forks":1010,"open_issues":63,"watchers":6233,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/plataformatec/simple_form/pulls/1398"},"html":{"href":"https://github.com/plataformatec/simple_form/pull/1398"},"issue":{"href":"https://api.github.com/repos/plataformatec/simple_form/issues/1398"},"comments":{"href":"https://api.github.com/repos/plataformatec/simple_form/issues/1398/comments"},"review_comments":{"href":"https://api.github.com/repos/plataformatec/simple_form/pulls/1398/comments"},"review_comment":{"href":"https://api.github.com/repos/plataformatec/simple_form/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/plataformatec/simple_form/pulls/1398/commits"},"statuses":{"href":"https://api.github.com/repos/plataformatec/simple_form/statuses/86ab4252ecad1956fa2ddeea2d62a1584dac10f6"}},"merged":false,"mergeable":false,"mergeable_state":"dirty","merged_by":null,"comments":9,"review_comments":2,"commits":1,"additions":17,"deletions":5,"changed_files":4}}
{"actor":{"display_login":"lucasmazza"}}