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

Establish working pattern for rendering partials from an exhibit with a freshly exhibited object. #51

Merged
merged 3 commits into from
Sep 10, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Change Log
All notable changes to this project will be documented in this file.


## Unreleased
### Added
- Change log (this file) (see: http://keepachangelog.com/)

### Fixed
- [#51](https://github.com/objects-on-rails/display-case/pull/51): Will now re-exhibit an exhibited model when rendering from an exhibit. This ensures that the exhibit chain includes all possible exhibit objects instead of just `self`. (by @pdobb)


## 0.1.0 - 2013-07-22
### Added
- [#47](https://github.com/objects-on-rails/display-case/pull/47): Ability to send an options hash to the `render` method. (by @pdobb)
- [#45](https://github.com/objects-on-rails/display-case/pull/45): Add `pop` as a query_method on DisplayCase::EnumerableExhibit. This ensures that `pop`ping the result of an exhibited list of objects returns an exhibited object. (by @pdobb)
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,17 @@ class LeagueExhibit < DisplayCase::Exhibit
end

def render_icon(template)
template.render(partial: 'leagues/icon', locals: {league: self})
# Use `object` local variable in partial to refer back to the exhibited
# object
render(template, partial: 'leagues/icon')

# OR

# Specify a local variable and "reexhibit" the model associated with `self`.
# Using `exhibit(to_model)` ensures that `league`'s exhibit chain includes
# all possible exhibit objects instead of just `self` (or LeagueExhibit,
# in this example).
render(template, partial: 'leagues/icon', locals: { league: exhibit(to_model) })
end
end
```
Expand Down Expand Up @@ -69,6 +79,8 @@ Finally, in your view, you can use your Exhibit:
<% end %>
```

Note: See [#51](https://github.com/objects-on-rails/display-case/pull/51) for more on the need for `exhibit(to_model)` when rendering a partial from an exhibit.

Configuration
-------------
Several configuration options can be set via an initializer:
Expand Down
2 changes: 1 addition & 1 deletion lib/display_case/exhibit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def inspect
end

def render(template, options = {})
template.render(options.reverse_merge(:partial => to_partial_path, :object => self))
template.render(options.reverse_merge(:partial => to_partial_path, :object => exhibit(to_model)))
end

def exhibited?
Expand Down