Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix breadcrumb links for namespaced parent models #2090

Merged
merged 1 commit into from Apr 10, 2013
Merged

Fix breadcrumb links for namespaced parent models #2090

merged 1 commit into from Apr 10, 2013

Conversation

seanlinsley
Copy link
Contributor

The previous code broke nested resource (e.g. /users/1/stories) had a
parent class that was namespaced inside a module.

# Given these models
class Foo::Users   # has_many stories
class Foo::Stories # belongs_to user

# and this AA routing for stories
ActiveAdmin.register Foo::Stories do
  belongs_to :user, parent_class: Foo::User
end

# you'd get this error
"undefined method `find_by_id' for Foo:Module"

This commit resolves the problem by directly asking the AA config
what the parent class is, instead of trying to guess based on the URL.

Fixes #2051

The previous code broke nested resource (e.g. /users/1/stories) had a
parent class that was namespaced inside a module.

```ruby
# Given these models
class Foo::Users   # has_many stories
class Foo::Stories # belongs_to user

# and this AA routing for stories
ActiveAdmin.register Foo::Stories do
  belongs_to :user, parent_class: Foo::User
end

# you'd get this error
"undefined method `find_by_id' for Foo:Module"
```

This commit resolves the problem by directly asking the AA config
what the parent class is, instead of trying to guess based on the URL.

Fixes #2051
@seanlinsley seanlinsley merged commit 3b4d776 into activeadmin:master Apr 10, 2013
@seanlinsley seanlinsley deleted the bugfix/breadcrumb-parent-class branch April 10, 2013 23:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant