bullet-train-co / bullet_train

The Open Source Ruby on Rails SaaS Template
MIT License
1.68k stars 269 forks source link

`shared/attributes/image` doesn't play well with empty images #1600

Closed jagthedrummer closed 4 months ago

jagthedrummer commented 4 months ago

If you super scaffold a model with an image field, and then create a record without uploading an image it breaks the index page with that record on it, and the show page for that record.

CleanShot 2024-07-11 at 11 37 29

Completed 500 Internal Server Error in 40ms (ActiveRecord: 5.1ms | Allocations: 30640)

ActionView::Template::Error (Nil location provided. Can't build URI.):
     7: <% if cloudinary_enabled? %>
     8:   <%= cloudinary_image_tag object.public_send(attribute), options %>
     9: <% else %>
    10:   <%= image_tag photo_url_for_active_storage_attachment(object.public_send(attribute), options) %>
    11: <% end %>

bullet_train-themes (1.7.15) app/views/themes/base/attributes/_image.html.erb:10
bullet_train-themes (1.7.15) app/helpers/current_theme_helper.rb:19:in `render'
app/views/account/issues/_issue.html.erb:14
bullet_train-fields (1.7.15) app/helpers/attributes_helper.rb:13:in `with_attribute_settings'
app/views/account/issues/_issue.html.erb:6
bullet_train-themes (1.7.15) app/helpers/current_theme_helper.rb:19:in `render'
app/views/account/issues/_index.html.erb:37
app/views/account/issues/_index.html.erb:19
bullet_train-themes (1.7.15) app/helpers/current_theme_helper.rb:19:in `render'
app/views/account/issues/_index.html.erb:12
app/views/account/issues/_index.html.erb:11
bullet_train-super_scaffolding (1.7.15) app/helpers/super_scaffolding_helper.rb:4:in `action_model_select_controller'
app/views/account/issues/_index.html.erb:10
bullet_train-themes (1.7.15) app/helpers/current_theme_helper.rb:19:in `render'
app/views/account/issues/index.html.erb:3
bullet_train-themes (1.7.15) app/helpers/current_theme_helper.rb:19:in `render'
app/views/account/issues/index.html.erb:1
bullet_train (1.7.15) app/controllers/concerns/controllers/base.rb:95:in `set_locale'