{"action":"created","issue":{"url":"https://api.github.com/repos/refinery/refinerycms/issues/2870","labels_url":"https://api.github.com/repos/refinery/refinerycms/issues/2870/labels{/name}","comments_url":"https://api.github.com/repos/refinery/refinerycms/issues/2870/comments","events_url":"https://api.github.com/repos/refinery/refinerycms/issues/2870/events","html_url":"https://github.com/refinery/refinerycms/issues/2870","id":55797445,"number":2870,"title":"Refactor page_title_with_translations method","user":{"login":"bricesanchez","id":1678530,"avatar_url":"https://avatars.githubusercontent.com/u/1678530?v=3","gravatar_id":"","url":"https://api.github.com/users/bricesanchez","html_url":"https://github.com/bricesanchez","followers_url":"https://api.github.com/users/bricesanchez/followers","following_url":"https://api.github.com/users/bricesanchez/following{/other_user}","gists_url":"https://api.github.com/users/bricesanchez/gists{/gist_id}","starred_url":"https://api.github.com/users/bricesanchez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bricesanchez/subscriptions","organizations_url":"https://api.github.com/users/bricesanchez/orgs","repos_url":"https://api.github.com/users/bricesanchez/repos","events_url":"https://api.github.com/users/bricesanchez/events{/privacy}","received_events_url":"https://api.github.com/users/bricesanchez/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-01-28T18:44:19Z","updated_at":"2015-01-28T20:35:15Z","closed_at":null,"body":"Hello !\r\n\r\nI would like to make this method more generic in order to be used by page engine and others like blog,...\r\n\r\nCould we do this  : \r\n```ruby\r\ndef title_with_translations(record)\r\n  record.title.presence || record.translations.detect { |t| t.title.present?}.title\r\nend\r\n```\r\n\r\nInstead of : \r\nhttps://github.com/refinery/refinerycms/blob/master/pages/app/helpers/refinery/admin/pages_helper.rb#L52\r\n```ruby\r\ndef page_title_with_translations(page)\r\n  page.title.presence || page.translations.detect { |t| t.title.present?}.title\r\nend\r\n```\r\n\r\nAnd move it in another helper who is load on every admin controllers like : \r\nhttps://github.com/refinery/refinerycms/blob/master/core/app/helpers/refinery/admin_helper.rb"},"comment":{"url":"https://api.github.com/repos/refinery/refinerycms/issues/comments/71910669","html_url":"https://github.com/refinery/refinerycms/issues/2870#issuecomment-71910669","issue_url":"https://api.github.com/repos/refinery/refinerycms/issues/2870","id":71910669,"user":{"login":"parndt","id":10128,"avatar_url":"https://avatars.githubusercontent.com/u/10128?v=3","gravatar_id":"","url":"https://api.github.com/users/parndt","html_url":"https://github.com/parndt","followers_url":"https://api.github.com/users/parndt/followers","following_url":"https://api.github.com/users/parndt/following{/other_user}","gists_url":"https://api.github.com/users/parndt/gists{/gist_id}","starred_url":"https://api.github.com/users/parndt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/parndt/subscriptions","organizations_url":"https://api.github.com/users/parndt/orgs","repos_url":"https://api.github.com/users/parndt/repos","events_url":"https://api.github.com/users/parndt/events{/privacy}","received_events_url":"https://api.github.com/users/parndt/received_events","type":"User","site_admin":false},"created_at":"2015-01-28T20:35:15Z","updated_at":"2015-01-28T20:35:15Z","body":"The official solution is to alias it to title but we could probably do better.\r\n\r\nThis whole situation would be better off as not a helper anyway as something like this: (cc @robyurkowski ?)\r\n\r\n```ruby\r\nclass TranslationPresenter\r\n  def initialize(record)\r\n    @record = record\r\n  end\r\n\r\n  def call(field)\r\n    record.send(field).presence || \r\n      record.translations.select {|t| t.send(field).presence}.compact.first\r\n  end\r\n\r\n  private\r\n  attr_accessor :record\r\nend\r\n```"}}