Skip to content

Providing optional: true and shallow: true together produces an error #868

@contentfree

Description

@contentfree

I have

class ConversationsController < InheritedResources::Base
  belongs_to :campaign, :subscriber, optional: true, shallow: true
end

but this leads to an error

NameError:
       `@' is not allowed as an instance variable name

     # /usr/local/bundle/gems/inherited_resources-1.13.1/lib/inherited_resources/belongs_to_helpers.rb:79:in `instance_variable_defined?'
     # /usr/local/bundle/gems/inherited_resources-1.13.1/lib/inherited_resources/belongs_to_helpers.rb:79:in `get_parent_ivar'
     # /usr/local/bundle/gems/inherited_resources-1.13.1/lib/inherited_resources/belongs_to_helpers.rb:74:in `evaluate_parent'
     # /usr/local/bundle/gems/inherited_resources-1.13.1/lib/inherited_resources/base_helpers.rb:131:in `block in association_chain'
     # /usr/local/bundle/gems/inherited_resources-1.13.1/lib/inherited_resources/base_helpers.rb:130:in `each'
     # /usr/local/bundle/gems/inherited_resources-1.13.1/lib/inherited_resources/base_helpers.rb:130:in `inject'
     # /usr/local/bundle/gems/inherited_resources-1.13.1/lib/inherited_resources/base_helpers.rb:130:in `association_chain'
     # /usr/local/bundle/gems/inherited_resources-1.13.1/lib/inherited_resources/base_helpers.rb:173:in `end_of_association_chain'

This a polymorphic and optional relationship. I'm hoping to be able to do this:

  • Visiting /conversations loads all conversations
  • Visiting /campaigns/1/conversations loads all of this campaign's conversations
  • Visiting /subscribers/1/conversations loads all of this subscriber's conversations
  • edit_resource_path with Conversation:1 at any of the above pages should always and only produce /conversations/1/edit
  • resource_path with Conversation:1 at any of the above pages should always and only produce /conversations/1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions