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

Nested collection links should honour routes #883

Merged
merged 1 commit into from
May 12, 2017
Merged

Nested collection links should honour routes #883

merged 1 commit into from
May 12, 2017

Conversation

karlentwistle
Copy link

@karlentwistle karlentwistle commented May 10, 2017

Prior to this commit if any routes where omitted for a resource like:

resources :users
resources :orders, except: [:edit, :update]

Navigating directly to a orders show page would correctly omit the edit link but if another associated dashboard utilised a field that rendered using the partial _collection.html.erb like:

class UserDashboard < Administrate::BaseDashboard
  ATTRIBUTE_TYPES = {
    orders: Field::HasMany,
  }

  SHOW_PAGE_ATTRIBUTES = ATTRIBUTE_TYPES.keys
end

when navigating to the users show page an error 500 would be thrown because the rendering of orders would incorrectly try to link to the non existent edit route

Fixes #790


visit admin_order_path(payment.order)

within('table') do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.


visit admin_order_path(payment.order)

within('table') do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

Prior to this commit if any routes where omitted for a resource like:

```
resources :users
resources :orders, except: [:edit, :update]
```

Navigating directly to a orders show page would correctly omit the
edit link but if another associated dashboard utilised a field that
rendered using the partial _collection.html.erb like:

```
class UserDashboard < Administrate::BaseDashboard
  ATTRIBUTE_TYPES = {
    orders: Field::HasMany,
  }

  SHOW_PAGE_ATTRIBUTES = ATTRIBUTE_TYPES.keys
end
```

when navigating to the users show page an error 500 would be thrown
because the rendering of orders would incorrectly try to link to the
non existent edit route

Fixes #790
@BenMorganIO
Copy link
Collaborator

BenMorganIO commented May 12, 2017

@karlentwistle very approved! Thank you ❤️

This makes having read-only routes more reliable.

@BenMorganIO BenMorganIO self-requested a review May 12, 2017 02:46
@nickcharlton
Copy link
Member

Thanks! Merging.

@nickcharlton nickcharlton merged commit b159b5c into thoughtbot:master May 12, 2017
iarie pushed a commit to iarie/administrate that referenced this pull request Jun 17, 2017
Prior to this commit if any routes where omitted for a resource like:

```
resources :users
resources :orders, except: [:edit, :update]
```

Navigating directly to a orders show page would correctly omit the
edit link but if another associated dashboard utilised a field that
rendered using the partial _collection.html.erb like:

```
class UserDashboard < Administrate::BaseDashboard
  ATTRIBUTE_TYPES = {
    orders: Field::HasMany,
  }

  SHOW_PAGE_ATTRIBUTES = ATTRIBUTE_TYPES.keys
end
```

when navigating to the users show page an error 500 would be thrown
because the rendering of orders would incorrectly try to link to the
non existent edit route

Fixes thoughtbot#790
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.

4 participants