Comments (3)
If I replace default: any
with default: { id: any }
in the yml, provided product exists, the editor works but then the previewer throws NoMethodError (undefined method `label' for nil:NilClass)
.
Click to see the full log
Started GET "/maglev/admin/sections/section_01/preview_in_frame" for ::1 at 2023-02-03 20:58:36 +0700
Processing by Maglev::Admin::Sections::PreviewsController#iframe_show as HTML
Parameters: {"id"=>"section_01"}
Maglev::Site Load (0.6ms) SELECT "maglev_sites".* FROM "maglev_sites" ORDER BY "maglev_sites"."id" ASC LIMIT $1 [["LIMIT", 1]]
Product Load (0.5ms) SELECT "products".* FROM "products" WHERE "products"."id" = $1 ORDER BY "products"."name" ASC LIMIT $2 [["id", nil], ["LIMIT", 1]]
Completed 500 Internal Server Error in 29ms (ActiveRecord: 8.5ms | Allocations: 8596)
NoMethodError (undefined method `label' for nil:NilClass):
maglevcms (1.1.7) app/services/concerns/maglev/get_page_sections/transform_collection_item_concern.rb:14:in `transform_collection_item_content_setting'
maglevcms (1.1.7) app/services/maglev/get_page_sections.rb:94:in `transform_content_setting'
maglevcms (1.1.7) app/services/maglev/get_page_sections.rb:83:in `block in transform_section_settings'
maglevcms (1.1.7) app/services/maglev/get_page_sections.rb:79:in `each'
maglevcms (1.1.7) app/services/maglev/get_page_sections.rb:79:in `transform_section_settings'
maglevcms (1.1.7) app/services/maglev/get_page_sections.rb:46:in `transform_section'
maglevcms (1.1.7) app/services/maglev/get_page_sections.rb:25:in `block in call'
maglevcms (1.1.7) app/services/maglev/get_page_sections.rb:24:in `map'
maglevcms (1.1.7) app/services/maglev/get_page_sections.rb:24:in `call'
maglev-injectable (2.1.1) lib/injectable/instance_methods.rb:18:in `call'
maglevcms (1.1.7) app/controllers/concerns/maglev/fetchers_concern.rb:38:in `fetch_maglev_page_sections'
maglevcms (1.1.7) app/controllers/concerns/maglev/fetchers_concern.rb:21:in `fetch_maglev_page_content'
maglevcms (1.1.7) app/controllers/concerns/maglev/rendering_concern.rb:16:in `render_maglev_page'
maglevcms (1.1.7) app/controllers/maglev/admin/sections/previews_controller.rb:17:in `iframe_show'
actionpack (7.0.4.2) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
actionpack (7.0.4.2) lib/abstract_controller/base.rb:215:in `process_action'
actionpack (7.0.4.2) lib/action_controller/metal/rendering.rb:53:in `process_action'
actionpack (7.0.4.2) lib/abstract_controller/callbacks.rb:234:in `block in process_action'
activesupport (7.0.4.2) lib/active_support/callbacks.rb:118:in `block in run_callbacks'
actiontext (7.0.4.2) lib/action_text/rendering.rb:20:in `with_renderer'
actiontext (7.0.4.2) lib/action_text/engine.rb:69:in `block (4 levels) in <class:Engine>'
activesupport (7.0.4.2) lib/active_support/callbacks.rb:127:in `instance_exec'
activesupport (7.0.4.2) lib/active_support/callbacks.rb:127:in `block in run_callbacks'
activesupport (7.0.4.2) lib/active_support/callbacks.rb:138:in `run_callbacks'
actionpack (7.0.4.2) lib/abstract_controller/callbacks.rb:233:in `process_action'
actionpack (7.0.4.2) lib/action_controller/metal/rescue.rb:22:in `process_action'
actionpack (7.0.4.2) lib/action_controller/metal/instrumentation.rb:67:in `block in process_action'
activesupport (7.0.4.2) lib/active_support/notifications.rb:206:in `block in instrument'
activesupport (7.0.4.2) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (7.0.4.2) lib/active_support/notifications.rb:206:in `instrument'
actionpack (7.0.4.2) lib/action_controller/metal/instrumentation.rb:66:in `process_action'
actionpack (7.0.4.2) lib/action_controller/metal/params_wrapper.rb:259:in `process_action'
activerecord (7.0.4.2) lib/active_record/railties/controller_runtime.rb:27:in `process_action'
actionpack (7.0.4.2) lib/abstract_controller/base.rb:151:in `process'
actionview (7.0.4.2) lib/action_view/rendering.rb:39:in `process'
actionpack (7.0.4.2) lib/action_controller/metal.rb:188:in `dispatch'
actionpack (7.0.4.2) lib/action_controller/metal.rb:251:in `dispatch'
actionpack (7.0.4.2) lib/action_dispatch/routing/route_set.rb:49:in `dispatch'
actionpack (7.0.4.2) lib/action_dispatch/routing/route_set.rb:32:in `serve'
actionpack (7.0.4.2) lib/action_dispatch/journey/router.rb:50:in `block in serve'
actionpack (7.0.4.2) lib/action_dispatch/journey/router.rb:32:in `each'
actionpack (7.0.4.2) lib/action_dispatch/journey/router.rb:32:in `serve'
actionpack (7.0.4.2) lib/action_dispatch/routing/route_set.rb:852:in `call'
railties (7.0.4.2) lib/rails/engine.rb:530:in `call'
railties (7.0.4.2) lib/rails/railtie.rb:226:in `public_send'
railties (7.0.4.2) lib/rails/railtie.rb:226:in `method_missing'
actionpack (7.0.4.2) lib/action_dispatch/routing/mapper.rb:19:in `block in <class:Constraints>'
actionpack (7.0.4.2) lib/action_dispatch/routing/mapper.rb:48:in `serve'
actionpack (7.0.4.2) lib/action_dispatch/journey/router.rb:50:in `block in serve'
actionpack (7.0.4.2) lib/action_dispatch/journey/router.rb:32:in `each'
actionpack (7.0.4.2) lib/action_dispatch/journey/router.rb:32:in `serve'
actionpack (7.0.4.2) lib/action_dispatch/routing/route_set.rb:852:in `call'
rack (2.2.6.2) lib/rack/tempfile_reaper.rb:15:in `call'
rack (2.2.6.2) lib/rack/etag.rb:27:in `call'
rack (2.2.6.2) lib/rack/conditional_get.rb:27:in `call'
rack (2.2.6.2) lib/rack/head.rb:12:in `call'
actionpack (7.0.4.2) lib/action_dispatch/http/permissions_policy.rb:38:in `call'
actionpack (7.0.4.2) lib/action_dispatch/http/content_security_policy.rb:36:in `call'
rack (2.2.6.2) lib/rack/session/abstract/id.rb:266:in `context'
rack (2.2.6.2) lib/rack/session/abstract/id.rb:260:in `call'
actionpack (7.0.4.2) lib/action_dispatch/middleware/cookies.rb:704:in `call'
activerecord (7.0.4.2) lib/active_record/migration.rb:603:in `call'
actionpack (7.0.4.2) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
activesupport (7.0.4.2) lib/active_support/callbacks.rb:99:in `run_callbacks'
actionpack (7.0.4.2) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (7.0.4.2) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (7.0.4.2) lib/action_dispatch/middleware/actionable_exceptions.rb:17:in `call'
actionpack (7.0.4.2) lib/action_dispatch/middleware/debug_exceptions.rb:28:in `call'
web-console (4.2.0) lib/web_console/middleware.rb:132:in `call_app'
web-console (4.2.0) lib/web_console/middleware.rb:28:in `block in call'
web-console (4.2.0) lib/web_console/middleware.rb:17:in `catch'
web-console (4.2.0) lib/web_console/middleware.rb:17:in `call'
actionpack (7.0.4.2) lib/action_dispatch/middleware/show_exceptions.rb:26:in `call'
railties (7.0.4.2) lib/rails/rack/logger.rb:40:in `call_app'
railties (7.0.4.2) lib/rails/rack/logger.rb:25:in `block in call'
activesupport (7.0.4.2) lib/active_support/tagged_logging.rb:99:in `block in tagged'
activesupport (7.0.4.2) lib/active_support/tagged_logging.rb:37:in `tagged'
activesupport (7.0.4.2) lib/active_support/tagged_logging.rb:99:in `tagged'
railties (7.0.4.2) lib/rails/rack/logger.rb:25:in `call'
sprockets-rails (3.4.2) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (7.0.4.2) lib/action_dispatch/middleware/remote_ip.rb:93:in `call'
actionpack (7.0.4.2) lib/action_dispatch/middleware/request_id.rb:26:in `call'
rack (2.2.6.2) lib/rack/method_override.rb:24:in `call'
rack (2.2.6.2) lib/rack/runtime.rb:22:in `call'
activesupport (7.0.4.2) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (7.0.4.2) lib/action_dispatch/middleware/server_timing.rb:61:in `block in call'
actionpack (7.0.4.2) lib/action_dispatch/middleware/server_timing.rb:26:in `collect_events'
actionpack (7.0.4.2) lib/action_dispatch/middleware/server_timing.rb:60:in `call'
actionpack (7.0.4.2) lib/action_dispatch/middleware/executor.rb:14:in `call'
rack (2.2.6.2) lib/rack/static.rb:161:in `call'
actionpack (7.0.4.2) lib/action_dispatch/middleware/static.rb:23:in `call'
rack (2.2.6.2) lib/rack/sendfile.rb:110:in `call'
actionpack (7.0.4.2) lib/action_dispatch/middleware/host_authorization.rb:137:in `call'
vite_ruby (3.2.14) lib/vite_ruby/dev_server_proxy.rb:22:in `perform_request'
rack-proxy (0.7.6) lib/rack/proxy.rb:87:in `call'
railties (7.0.4.2) lib/rails/engine.rb:530:in `call'
puma (5.6.5) lib/puma/configuration.rb:252:in `call'
puma (5.6.5) lib/puma/request.rb:77:in `block in handle_request'
puma (5.6.5) lib/puma/thread_pool.rb:340:in `with_force_shutdown'
puma (5.6.5) lib/puma/request.rb:76:in `handle_request'
puma (5.6.5) lib/puma/server.rb:443:in `process_client'
puma (5.6.5) lib/puma/thread_pool.rb:147:in `block in spawn_thread'
Conclusion:
- Editor works only if the value is the ID (e.g.
any
) and record can be found - Previewer works only if the value is a hash containing the ID (e.g.
{ id: any }
) and record can be found - Both editor and previewer can't handle missing record (
nil
)
Recommended solution:
- Generator, editor, and previewer use to the same format
- Both editor and previewer can handle missing record
from maglev-core.
@cmdr-rohit-bang Sorry for the delayed response, just noticed your message by now.
Indeed, collection_item
is intended for one record only, not for multiple records.
For multiple records, you can follow this step, like this:
app/theme/sections/blog/latest_blogs.yml
# ...
settings:
- label: "Number of blogs"
id: number_of_blogs
type: select # or "text" for more dynamic limit
select_options:
- label: "Last 2 blogs"
value: "2"
- label: "Last 3 blogs"
value: "3"
- label: "Last 4 blogs"
value: "4"
- label: "Last 5 blogs"
value: "5"
default: "2"
# ...
app/views/theme/sections/blog/latest_blogs.html.erb
<%= maglev_section.wrapper_tag.ul class: 'mx-auto list-disc' do %>
<% Blog.order(:created_at).limit(maglev_section.settings.number_of_blogs.value.to_i).each do |blog| %>
<li><%= link_to blog.title, main_app.blog_path(blog) %></li>
<% end %>
<% end %>
I hope that helps.
from maglev-core.
@hasaniskandar I got the expected behaviour working but got only 1 row, the query is executed with limit 1.
settings:
- label: "Blog"
id: blog
type: collection_item
collection_id: blogs
default: any
Any idea how can I execute query without limit or increase limit?
Thanks in advance
from maglev-core.
Related Issues (20)
- Can you please update this `vite-plugin-ruby ` version to 3.2.2 ?
- Create versions of predefined pages in other locales
- Maglev PRO Version HOT 1
- Internal Error: maglev@workspace:.: This package doesn't seem to be present in your lockfile HOT 3
- Running Installer - Vite Compatibility Issue HOT 5
- Homepage video broken HOT 1
- Can't have two sections with same name in different categories
- Rails 7.1 support HOT 4
- Headless progress HOT 2
- Page Search by path incorrectly searches locale
- Install fails on first step of guide because of vite incompatibility HOT 6
- Unable to upload or display uploaded images when using UUIDs and Postgres HOT 17
- docs.maglev.dev/guides/i18n does not exist HOT 1
- Switching language while preserving site location HOT 1
- Fatal error: Integer does not have #dig method HOT 1
- How to modify frontend editor files HOT 1
- Options to add submenus not available HOT 1
- Installation error HOT 1
- Yarn install failing
- Error while following Quick start HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from maglev-core.