{"action":"created","comment":{"url":"https://api.github.com/repos/spree/spree/pulls/comments/23641613","id":23641613,"diff_hunk":"@@ -100,159 +100,155 @@ def destroy\n \n   protected\n \n-    class << self\n-      attr_accessor :parent_data\n+  class << self\n+    attr_accessor :parent_data\n \n-      def belongs_to(model_name, options = {})\n-        @parent_data ||= {}\n-        @parent_data[:model_name] = model_name\n-        @parent_data[:model_class] = model_name.to_s.classify.constantize\n-        @parent_data[:find_by] = options[:find_by] || :id\n-      end\n-    end\n-\n-    def resource_not_found\n-      flash[:error] = flash_message_for(model_class.new, :not_found)\n-      redirect_to collection_url\n-    end\n-\n-    def model_class\n-      \"Spree::#{controller_name.classify}\".constantize\n+    def belongs_to(model_name, options = {})\n+      @parent_data ||= {}\n+      @parent_data[:model_name] = model_name\n+      @parent_data[:model_class] = model_name.to_s.classify.constantize\n+      @parent_data[:find_by] = options[:find_by] || :id\n     end\n+  end\n \n-    def model_name\n-      parent_data[:model_name].gsub('spree/', '')\n-    end\n+  def resource_not_found\n+    flash[:error] = flash_message_for(resource.model_class.new, :not_found)\n+    redirect_to collection_url\n+  end\n \n-    def object_name\n-      controller_name.singularize\n+  def resource\n+    return @resource if @resource\n+    if parent_data\n+      parent_model_name = parent_data[:model_name]\n     end\n+    @resource = Spree::Admin::Resource.new controller_path, controller_name, parent_model_name\n+  end\n \n-    def load_resource\n-      if member_action?\n-        @object ||= load_resource_instance\n+  def load_resource\n+    if member_action?\n+      @object ||= load_resource_instance\n \n-        # call authorize! a third time (called twice already in Admin::BaseController)\n-        # this time we pass the actual instance so fine-grained abilities can control\n-        # access to individual records, not just entire models.\n-        authorize! action, @object\n+      # call authorize! a third time (called twice already in Admin::BaseController)\n+      # this time we pass the actual instance so fine-grained abilities can control\n+      # access to individual records, not just entire models.\n+      authorize! action, @object\n \n-        instance_variable_set(\"@#{object_name}\", @object)\n-      else\n-        @collection ||= collection\n+      instance_variable_set(\"@#{resource.object_name}\", @object)\n+    else\n+      @collection ||= collection\n \n-        # note: we don't call authorize here as the collection method should use\n-        # CanCan's accessible_by method to restrict the actual records returned\n+      # note: we don't call authorize here as the collection method should use\n+      # CanCan's accessible_by method to restrict the actual records returned\n \n-        instance_variable_set(\"@#{controller_name}\", @collection)\n-      end\n+      instance_variable_set(\"@#{controller_name}\", @collection)\n     end\n+  end\n \n-    def load_resource_instance\n-      if new_actions.include?(action)\n-        build_resource\n-      elsif params[:id]\n-        find_resource\n-      end\n+  def load_resource_instance\n+    if new_actions.include?(action)\n+      build_resource\n+    elsif params[:id]\n+      find_resource\n     end\n+  end\n \n-    def parent_data\n-      self.class.parent_data\n-    end\n+  def parent_data\n+    self.class.parent_data\n+  end\n \n-    def parent\n-      if parent_data.present?\n-        @parent ||= parent_data[:model_class].send(\"find_by_#{parent_data[:find_by]}\", params[\"#{model_name}_id\"])\n-        instance_variable_set(\"@#{model_name}\", @parent)\n-      else\n-        nil\n-      end\n+  def parent\n+    if parent_data.present?\n+      @parent ||= parent_data[:model_class].send(\"find_by_#{parent_data[:find_by]}\", params[\"#{resource.model_name}_id\"])","path":"backend/app/controllers/spree/admin/resource_controller.rb","position":123,"original_position":123,"commit_id":"2cfbfb480e7be09fc6208dd920185481e93a4d73","original_commit_id":"2cfbfb480e7be09fc6208dd920185481e93a4d73","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"Line is too long. [121/100]","created_at":"2015-01-27T20:51:49Z","updated_at":"2015-01-27T20:51:49Z","html_url":"https://github.com/spree/spree/pull/5954#discussion_r23641613","pull_request_url":"https://api.github.com/repos/spree/spree/pulls/5954","_links":{"self":{"href":"https://api.github.com/repos/spree/spree/pulls/comments/23641613"},"html":{"href":"https://github.com/spree/spree/pull/5954#discussion_r23641613"},"pull_request":{"href":"https://api.github.com/repos/spree/spree/pulls/5954"}}},"pull_request":{"url":"https://api.github.com/repos/spree/spree/pulls/5954","id":28060215,"html_url":"https://github.com/spree/spree/pull/5954","diff_url":"https://github.com/spree/spree/pull/5954.diff","patch_url":"https://github.com/spree/spree/pull/5954.patch","issue_url":"https://api.github.com/repos/spree/spree/issues/5954","number":5954,"state":"open","locked":false,"title":"Allow resources within modules to use ResourcesController.","user":{"login":"MattDunbar","id":445619,"avatar_url":"https://avatars.githubusercontent.com/u/445619?v=3","gravatar_id":"","url":"https://api.github.com/users/MattDunbar","html_url":"https://github.com/MattDunbar","followers_url":"https://api.github.com/users/MattDunbar/followers","following_url":"https://api.github.com/users/MattDunbar/following{/other_user}","gists_url":"https://api.github.com/users/MattDunbar/gists{/gist_id}","starred_url":"https://api.github.com/users/MattDunbar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MattDunbar/subscriptions","organizations_url":"https://api.github.com/users/MattDunbar/orgs","repos_url":"https://api.github.com/users/MattDunbar/repos","events_url":"https://api.github.com/users/MattDunbar/events{/privacy}","received_events_url":"https://api.github.com/users/MattDunbar/received_events","type":"User","site_admin":false},"body":"This will apply cleanly on 2-2, 2-3 and 2-4, unconfirmed for prior releases.","created_at":"2015-01-26T21:05:36Z","updated_at":"2015-01-27T20:51:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d35cb5126fa051d15ea1b1fdb506002889f77ae8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/spree/spree/pulls/5954/commits","review_comments_url":"https://api.github.com/repos/spree/spree/pulls/5954/comments","review_comment_url":"https://api.github.com/repos/spree/spree/pulls/comments/{number}","comments_url":"https://api.github.com/repos/spree/spree/issues/5954/comments","statuses_url":"https://api.github.com/repos/spree/spree/statuses/2cfbfb480e7be09fc6208dd920185481e93a4d73","head":{"label":"MattDunbar:master","ref":"master","sha":"2cfbfb480e7be09fc6208dd920185481e93a4d73","user":{"login":"MattDunbar","id":445619,"avatar_url":"https://avatars.githubusercontent.com/u/445619?v=3","gravatar_id":"","url":"https://api.github.com/users/MattDunbar","html_url":"https://github.com/MattDunbar","followers_url":"https://api.github.com/users/MattDunbar/followers","following_url":"https://api.github.com/users/MattDunbar/following{/other_user}","gists_url":"https://api.github.com/users/MattDunbar/gists{/gist_id}","starred_url":"https://api.github.com/users/MattDunbar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MattDunbar/subscriptions","organizations_url":"https://api.github.com/users/MattDunbar/orgs","repos_url":"https://api.github.com/users/MattDunbar/repos","events_url":"https://api.github.com/users/MattDunbar/events{/privacy}","received_events_url":"https://api.github.com/users/MattDunbar/received_events","type":"User","site_admin":false},"repo":{"id":29880484,"name":"spree","full_name":"MattDunbar/spree","owner":{"login":"MattDunbar","id":445619,"avatar_url":"https://avatars.githubusercontent.com/u/445619?v=3","gravatar_id":"","url":"https://api.github.com/users/MattDunbar","html_url":"https://github.com/MattDunbar","followers_url":"https://api.github.com/users/MattDunbar/followers","following_url":"https://api.github.com/users/MattDunbar/following{/other_user}","gists_url":"https://api.github.com/users/MattDunbar/gists{/gist_id}","starred_url":"https://api.github.com/users/MattDunbar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MattDunbar/subscriptions","organizations_url":"https://api.github.com/users/MattDunbar/orgs","repos_url":"https://api.github.com/users/MattDunbar/repos","events_url":"https://api.github.com/users/MattDunbar/events{/privacy}","received_events_url":"https://api.github.com/users/MattDunbar/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/MattDunbar/spree","description":"Spree is a complete open source e-commerce solution for Ruby on Rails.","fork":true,"url":"https://api.github.com/repos/MattDunbar/spree","forks_url":"https://api.github.com/repos/MattDunbar/spree/forks","keys_url":"https://api.github.com/repos/MattDunbar/spree/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MattDunbar/spree/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MattDunbar/spree/teams","hooks_url":"https://api.github.com/repos/MattDunbar/spree/hooks","issue_events_url":"https://api.github.com/repos/MattDunbar/spree/issues/events{/number}","events_url":"https://api.github.com/repos/MattDunbar/spree/events","assignees_url":"https://api.github.com/repos/MattDunbar/spree/assignees{/user}","branches_url":"https://api.github.com/repos/MattDunbar/spree/branches{/branch}","tags_url":"https://api.github.com/repos/MattDunbar/spree/tags","blobs_url":"https://api.github.com/repos/MattDunbar/spree/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MattDunbar/spree/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MattDunbar/spree/git/refs{/sha}","trees_url":"https://api.github.com/repos/MattDunbar/spree/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MattDunbar/spree/statuses/{sha}","languages_url":"https://api.github.com/repos/MattDunbar/spree/languages","stargazers_url":"https://api.github.com/repos/MattDunbar/spree/stargazers","contributors_url":"https://api.github.com/repos/MattDunbar/spree/contributors","subscribers_url":"https://api.github.com/repos/MattDunbar/spree/subscribers","subscription_url":"https://api.github.com/repos/MattDunbar/spree/subscription","commits_url":"https://api.github.com/repos/MattDunbar/spree/commits{/sha}","git_commits_url":"https://api.github.com/repos/MattDunbar/spree/git/commits{/sha}","comments_url":"https://api.github.com/repos/MattDunbar/spree/comments{/number}","issue_comment_url":"https://api.github.com/repos/MattDunbar/spree/issues/comments/{number}","contents_url":"https://api.github.com/repos/MattDunbar/spree/contents/{+path}","compare_url":"https://api.github.com/repos/MattDunbar/spree/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MattDunbar/spree/merges","archive_url":"https://api.github.com/repos/MattDunbar/spree/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MattDunbar/spree/downloads","issues_url":"https://api.github.com/repos/MattDunbar/spree/issues{/number}","pulls_url":"https://api.github.com/repos/MattDunbar/spree/pulls{/number}","milestones_url":"https://api.github.com/repos/MattDunbar/spree/milestones{/number}","notifications_url":"https://api.github.com/repos/MattDunbar/spree/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MattDunbar/spree/labels{/name}","releases_url":"https://api.github.com/repos/MattDunbar/spree/releases{/id}","created_at":"2015-01-26T20:39:05Z","updated_at":"2015-01-27T20:51:43Z","pushed_at":"2015-01-27T20:51:43Z","git_url":"git://github.com/MattDunbar/spree.git","ssh_url":"git@github.com:MattDunbar/spree.git","clone_url":"https://github.com/MattDunbar/spree.git","svn_url":"https://github.com/MattDunbar/spree","homepage":"http://spreecommerce.com","size":72081,"stargazers_count":0,"watchers_count":0,"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":0,"default_branch":"master"}},"base":{"label":"spree:master","ref":"master","sha":"738044246794ada85206d2f70f19b4ddcbdc4de4","user":{"login":"spree","id":56702,"avatar_url":"https://avatars.githubusercontent.com/u/56702?v=3","gravatar_id":"","url":"https://api.github.com/users/spree","html_url":"https://github.com/spree","followers_url":"https://api.github.com/users/spree/followers","following_url":"https://api.github.com/users/spree/following{/other_user}","gists_url":"https://api.github.com/users/spree/gists{/gist_id}","starred_url":"https://api.github.com/users/spree/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spree/subscriptions","organizations_url":"https://api.github.com/users/spree/orgs","repos_url":"https://api.github.com/users/spree/repos","events_url":"https://api.github.com/users/spree/events{/privacy}","received_events_url":"https://api.github.com/users/spree/received_events","type":"Organization","site_admin":false},"repo":{"id":3314,"name":"spree","full_name":"spree/spree","owner":{"login":"spree","id":56702,"avatar_url":"https://avatars.githubusercontent.com/u/56702?v=3","gravatar_id":"","url":"https://api.github.com/users/spree","html_url":"https://github.com/spree","followers_url":"https://api.github.com/users/spree/followers","following_url":"https://api.github.com/users/spree/following{/other_user}","gists_url":"https://api.github.com/users/spree/gists{/gist_id}","starred_url":"https://api.github.com/users/spree/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spree/subscriptions","organizations_url":"https://api.github.com/users/spree/orgs","repos_url":"https://api.github.com/users/spree/repos","events_url":"https://api.github.com/users/spree/events{/privacy}","received_events_url":"https://api.github.com/users/spree/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/spree/spree","description":"Spree is a complete open source e-commerce solution for Ruby on Rails.","fork":false,"url":"https://api.github.com/repos/spree/spree","forks_url":"https://api.github.com/repos/spree/spree/forks","keys_url":"https://api.github.com/repos/spree/spree/keys{/key_id}","collaborators_url":"https://api.github.com/repos/spree/spree/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/spree/spree/teams","hooks_url":"https://api.github.com/repos/spree/spree/hooks","issue_events_url":"https://api.github.com/repos/spree/spree/issues/events{/number}","events_url":"https://api.github.com/repos/spree/spree/events","assignees_url":"https://api.github.com/repos/spree/spree/assignees{/user}","branches_url":"https://api.github.com/repos/spree/spree/branches{/branch}","tags_url":"https://api.github.com/repos/spree/spree/tags","blobs_url":"https://api.github.com/repos/spree/spree/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/spree/spree/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/spree/spree/git/refs{/sha}","trees_url":"https://api.github.com/repos/spree/spree/git/trees{/sha}","statuses_url":"https://api.github.com/repos/spree/spree/statuses/{sha}","languages_url":"https://api.github.com/repos/spree/spree/languages","stargazers_url":"https://api.github.com/repos/spree/spree/stargazers","contributors_url":"https://api.github.com/repos/spree/spree/contributors","subscribers_url":"https://api.github.com/repos/spree/spree/subscribers","subscription_url":"https://api.github.com/repos/spree/spree/subscription","commits_url":"https://api.github.com/repos/spree/spree/commits{/sha}","git_commits_url":"https://api.github.com/repos/spree/spree/git/commits{/sha}","comments_url":"https://api.github.com/repos/spree/spree/comments{/number}","issue_comment_url":"https://api.github.com/repos/spree/spree/issues/comments/{number}","contents_url":"https://api.github.com/repos/spree/spree/contents/{+path}","compare_url":"https://api.github.com/repos/spree/spree/compare/{base}...{head}","merges_url":"https://api.github.com/repos/spree/spree/merges","archive_url":"https://api.github.com/repos/spree/spree/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/spree/spree/downloads","issues_url":"https://api.github.com/repos/spree/spree/issues{/number}","pulls_url":"https://api.github.com/repos/spree/spree/pulls{/number}","milestones_url":"https://api.github.com/repos/spree/spree/milestones{/number}","notifications_url":"https://api.github.com/repos/spree/spree/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/spree/spree/labels{/name}","releases_url":"https://api.github.com/repos/spree/spree/releases{/id}","created_at":"2008-03-10T14:45:35Z","updated_at":"2015-01-27T14:27:08Z","pushed_at":"2015-01-27T13:55:34Z","git_url":"git://github.com/spree/spree.git","ssh_url":"git@github.com:spree/spree.git","clone_url":"https://github.com/spree/spree.git","svn_url":"https://github.com/spree/spree","homepage":"http://spreecommerce.com","size":127501,"stargazers_count":5882,"watchers_count":5882,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2750,"mirror_url":null,"open_issues_count":90,"forks":2750,"open_issues":90,"watchers":5882,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/spree/spree/pulls/5954"},"html":{"href":"https://github.com/spree/spree/pull/5954"},"issue":{"href":"https://api.github.com/repos/spree/spree/issues/5954"},"comments":{"href":"https://api.github.com/repos/spree/spree/issues/5954/comments"},"review_comments":{"href":"https://api.github.com/repos/spree/spree/pulls/5954/comments"},"review_comment":{"href":"https://api.github.com/repos/spree/spree/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/spree/spree/pulls/5954/commits"},"statuses":{"href":"https://api.github.com/repos/spree/spree/statuses/2cfbfb480e7be09fc6208dd920185481e93a4d73"}}}}