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

Exception when rendering the essence picture view without options / html_options #2083

Closed
afdev82 opened this issue May 4, 2021 · 2 comments · Fixed by #2099
Closed

Exception when rendering the essence picture view without options / html_options #2083

afdev82 opened this issue May 4, 2021 · 2 comments · Fixed by #2099

Comments

@afdev82
Copy link
Contributor

afdev82 commented May 4, 2021

Steps to reproduce

Following the instructions in this PR I'm removing the calls to render_essence_view in order to upgrade to AlchemyCMS v5:
From

render_essence_view(@entry.content_by_name(:image), size: '624x442')

To

render @entry.content_by_name(:image), { options: { size: '624x442' }} 

Expected behavior

It renders the partial correctly

Actual behavior

I get the following exception:

no implicit conversion of nil into Hash

alchemy_cms (4.6.2) app/models/alchemy/essence_picture_view.rb:62:in `merge'
alchemy_cms (4.6.2) app/models/alchemy/essence_picture_view.rb:62:in `img_tag'
alchemy_cms (4.6.2) app/models/alchemy/essence_picture_view.rb:30:in `render'
app/views/alchemy/essences/_essence_picture_view.html.erb:6:in `_app_views_alchemy_essences__essence_picture_view_html_erb___845792079704803411_105160'

System configuration

  • Alchemy Version: v4.6.2
  • Rails Version: v5.2.5

I think I already found the reason for that.
The code here should be changed to

  local_assigns[:options] || {},
  local_assigns[:html_options] || {}

Because both keys are optional.

The variable local_assigns[:html_options] in my case is nil and the default parameter is not considered in the initialize function.
The result is that the variable is nil and not an Hash at this point, causing the exception.

If my fix is correct, I will provide a PR. Also the new versions are affected, the code is the same also on the latest.

@tvdeyen
Copy link
Member

tvdeyen commented May 13, 2021

You are right. Please open a PR to the main branch. We will then backport.

tvdeyen added a commit that referenced this issue May 17, 2021
tvdeyen pushed a commit that referenced this issue May 17, 2021
Allow to render the essence picture view without options / html_options
tvdeyen pushed a commit that referenced this issue May 17, 2021
Allow to render the essence picture view without options / html_options
tvdeyen pushed a commit that referenced this issue May 17, 2021
Allow to render the essence picture view without options / html_options
@tvdeyen
Copy link
Member

tvdeyen commented May 17, 2021

backported down to 5.0-stable

robinboening pushed a commit to robinboening/alchemy_cms that referenced this issue Jul 2, 2021
Allow to render the essence picture view without options / html_options
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants