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

prepare_parameters raises exception when parameters nil #345

Open
tillcarlos opened this issue Nov 21, 2019 · 1 comment
Open

prepare_parameters raises exception when parameters nil #345

tillcarlos opened this issue Nov 21, 2019 · 1 comment
Assignees

Comments

@tillcarlos
Copy link

Hey guys. First: great work! This is exactly the gem I was searching for.

On my dev+production machine sometimes activities get created with parameters being nil.

Then this code fails

    def prepare_parameters(params)
      @prepared_params ||= self.parameters.with_indifferent_access.merge(params)
    end

with_indifferent_access called on nil object.

I'm fixing it in the view with this:

<% @activities.each do |activity| %>
  <% activity.parameters ||= {} %>
  <%= render_activities(activity) %>
<% end %>

But it's weird that it's necessary. Maybe because I changed my migration to t.json "parameters" ? Default was text, but that crashed on my production machine (a vanilla dokku install... I did not check why text did not work, but json worked. If it's relevant I can investigate).

Wouldn't it make sense to just put in the default? Or change that method to always hand out at least empty hash? {}

@tmyengstrom
Copy link

tmyengstrom commented Nov 4, 2020

Hi, Experience the same Error. I tried this workaround. But I still get an error in my production environment on Heroku. (it works fine on my local server)

Any ideas on how I can resolve this? Here's what I get back from my Heroku Logs.

[9972b504-118f-45f9-Completed 500 Internal Server Error in 128ms (ActiveRecord: 36.2ms | Allocations: 14844)

ActionView::Template::Error (undefined method `with_indifferent_access' for "{}":String):
<div class="grid md:grid-cols-12 md:mr-12 my-5 md:ml-24">
<% @activities.each do |activity| %>
 <% activity.parameters ||= {} %>
<%= render_activities(activity) %>
<% end %>
</div>

@ur5us ur5us self-assigned this May 15, 2022
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

No branches or pull requests

3 participants