class Marten::Handlers::RecordDetail
Overview
Handler allowing to display a specific model record.
This handler can be used to showcase a specific model record. It is expected that the handler will be accessed through a GET request only: as part of this request, the configured template is rendered and displayed (and the retrieved model record is inserted into the template context)
class MyRecordHandler < Marten::Handlers::RecordDetail
model MyModel
template_name "my_record.html"
end
The model class used to retrieve the record can be configured through the use of the #model
macro. The
#template_name
class method allows to define the name of the template to use to render the model record.
Included Modules
Extended Modules
Defined in:
marten/handlers/record_detail.crClass Method Summary
-
.lookup_field : String
Returns the name of the model field that will be used to retrieve the record (defaults to
pk
). -
.record_context_name(name : String | Symbol)
Allows to configure the name to use to include the model record into the template context.
-
.record_context_name : String
Returns the name to use to include the model record into the template context (defaults to
record
).
Instance Method Summary
-
#context
Returns a hash containing the template context or
nil
.
Instance methods inherited from module Marten::Handlers::RecordRetrieving
model
model,
queryset
queryset,
record
record
Macros inherited from module Marten::Handlers::RecordRetrieving
model(model_klass)
model
Instance methods inherited from class Marten::Handlers::Template
context
context,
get
get
Class methods inherited from class Marten::Handlers::Template
template_name : String | Nil
template_name
Instance methods inherited from module Marten::Handlers::Rendering
get_response(content)
get_response,
render_template(context : Hash | NamedTuple | Nil | Marten::Template::Context)
render_template,
render_to_response(context : Hash | NamedTuple | Nil | Marten::Template::Context)
render_to_response,
template_name : String
template_name
Instance methods inherited from class Marten::Handlers::Base
delete
delete,
dispatch : Marten::HTTP::Response
dispatch,
get
get,
head(status : Int32) : HTTP::Responsehead head, json(raw_json : String, status = 200)
json(serializable, status = 200) json, options options, params : Hash(String, Int16 | Int32 | Int64 | Int8 | String | UInt16 | UInt32 | UInt64 | UInt8 | UUID) params, patch patch, post post, put put, redirect(url : String, permanent = false) redirect, render(template_name : String, context : Hash | NamedTuple | Nil | Marten::Template::Context = nil, content_type = HTTP::Response::DEFAULT_CONTENT_TYPE, status = 200) render, request : Marten::HTTP::Request request, respond(streamed_content : Iterator(String), content_type = HTTP::Response::DEFAULT_CONTENT_TYPE, status = 200)
respond(content = "", content_type = HTTP::Response::DEFAULT_CONTENT_TYPE, status = 200) respond, response : Marten::HTTP::Response? response, response! response!, reverse(*args, **options)
reverse(*args, **options, &) reverse, trace trace
Constructor methods inherited from class Marten::Handlers::Base
new(request : HTTP::Request, params : ParamsHash)new(request : HTTP::Request, **kwargs) new
Class methods inherited from class Marten::Handlers::Base
content_security_policy_block
content_security_policy_block,
http_method_nameshttp_method_names(*method_names : String | Symbol) http_method_names
Instance methods inherited from module Marten::Handlers::Session
session(*args, **options)session(*args, **options, &) session
Instance methods inherited from module Marten::Handlers::RequestForgeryProtection
get_csrf_token
get_csrf_token,
referer_trusted?
referer_trusted?
Instance methods inherited from module Marten::Handlers::Flash
flash(*args, **options)flash(*args, **options, &) flash
Instance methods inherited from module Marten::Handlers::Cookies
cookies(*args, **options)cookies(*args, **options, &) cookies
Macros inherited from module Marten::Handlers::Callbacks
after_dispatch(*names)
after_dispatch,
before_dispatch(*names)
before_dispatch
Class Method Detail
Returns the name of the model field that will be used to retrieve the record (defaults to pk
).
Allows to configure the name to use to include the model record into the template context.
Returns the name to use to include the model record into the template context (defaults to record
).
Instance Method Detail
Returns a hash containing the template context or nil
.
The default implementation returns nil
.