吝吻

文章 评论 浏览 30

吝吻 2025-02-21 01:57:37

这可能对别人有用,这是解决方案

Container(
                    height: 550,
                    child: ListView.builder(
                        itemCount: listName['allItems'].length,
                        itemBuilder: (context, index){
                        Map allItems = listName;

                              return InkWell(
                              child: Card(
                              child: ListTile(
                              leading: Icon(Icons.skip_next_rounded),
                              title:
                                  Text((allItems['allItems'][index]['itemName'])),
                              onTap:(){},
                              ),

                         ));}),
                  )

It might be usefull to someone else, here is the solution

Container(
                    height: 550,
                    child: ListView.builder(
                        itemCount: listName['allItems'].length,
                        itemBuilder: (context, index){
                        Map allItems = listName;

                              return InkWell(
                              child: Card(
                              child: ListTile(
                              leading: Icon(Icons.skip_next_rounded),
                              title:
                                  Text((allItems['allItems'][index]['itemName'])),
                              onTap:(){},
                              ),

                         ));}),
                  )

firebase,无法在数组中显示地图的记录到视图中

吝吻 2025-02-20 20:50:30

这是正确的答案:

#Import necessary libraries
from time import sleep
import RPi.GPIO as GPIO
import telegram_send

sensor = 21 # The sensor is on GPIO pin 21
OPEN_DOOR = 1 # The state of the sensor is 1 when the door is open
CLOSED_DOOR = 0 # The state of the sensor is 0 when the door is closed

DOOR_LAST_STATE = -1

# Send the message

if __name__ == '__main__':
    # Sets the GPIO pinout to BCM
    GPIO.setmode(GPIO.BCM)
    # Pull the sensor to 3.3v when not engaged, It will be pulled to ground when engaged
    GPIO.setup(sensor,GPIO.IN,pull_up_down=GPIO.PUD_UP)

    # Recovering current state of the door
    DOOR_LAST_STATE = GPIO.input(sensor)

    # Main Event Loop
    # ------------------------------------------------------------------------

    print("Program started!")

    while True:
        curr_state = GPIO.input(sensor)
        if curr_state == OPEN_DOOR: # If the door is open
            if DOOR_LAST_STATE == CLOSED_DOOR: # And the las known state is "closed"
                print("The door is open") # Send the message 
                telegram_send.send(messages=["The door is open!"])
                DOOR_LAST_STATE = OPEN_DOOR # And upate the last known state to "open"

            elif DOOR_LAST_STATE == OPEN_DOOR: # But if the last known state is the same as the current
                print("The door is still open")
                # Do Nothing

            else:
                print("The door is at unknow state")

        elif curr_state == CLOSED_DOOR: # If the door is closed
            if DOOR_LAST_STATE == OPEN_DOOR:  # And the last know state is open
                print("The door is closed") # Send the message
                telegram_send.send(messages=["The door is closed!"])
                DOOR_LAST_STATE = CLOSED_DOOR # And update the last known state to "closed"

            elif DOOR_LAST_STATE == CLOSED_DOOR: # If the last known state is te same as the current
                print("The door is still closed")
                # Do Nothing

            else:
                print("The door is at unknow state")

        else:
            print("The door is at unknow state")

        sleep(1)  # What we do we will always sleep at the end

        # ------------------------------------------------------------------------
        # End of loop

Here is the correct answer:

#Import necessary libraries
from time import sleep
import RPi.GPIO as GPIO
import telegram_send

sensor = 21 # The sensor is on GPIO pin 21
OPEN_DOOR = 1 # The state of the sensor is 1 when the door is open
CLOSED_DOOR = 0 # The state of the sensor is 0 when the door is closed

DOOR_LAST_STATE = -1

# Send the message

if __name__ == '__main__':
    # Sets the GPIO pinout to BCM
    GPIO.setmode(GPIO.BCM)
    # Pull the sensor to 3.3v when not engaged, It will be pulled to ground when engaged
    GPIO.setup(sensor,GPIO.IN,pull_up_down=GPIO.PUD_UP)

    # Recovering current state of the door
    DOOR_LAST_STATE = GPIO.input(sensor)

    # Main Event Loop
    # ------------------------------------------------------------------------

    print("Program started!")

    while True:
        curr_state = GPIO.input(sensor)
        if curr_state == OPEN_DOOR: # If the door is open
            if DOOR_LAST_STATE == CLOSED_DOOR: # And the las known state is "closed"
                print("The door is open") # Send the message 
                telegram_send.send(messages=["The door is open!"])
                DOOR_LAST_STATE = OPEN_DOOR # And upate the last known state to "open"

            elif DOOR_LAST_STATE == OPEN_DOOR: # But if the last known state is the same as the current
                print("The door is still open")
                # Do Nothing

            else:
                print("The door is at unknow state")

        elif curr_state == CLOSED_DOOR: # If the door is closed
            if DOOR_LAST_STATE == OPEN_DOOR:  # And the last know state is open
                print("The door is closed") # Send the message
                telegram_send.send(messages=["The door is closed!"])
                DOOR_LAST_STATE = CLOSED_DOOR # And update the last known state to "closed"

            elif DOOR_LAST_STATE == CLOSED_DOOR: # If the last known state is te same as the current
                print("The door is still closed")
                # Do Nothing

            else:
                print("The door is at unknow state")

        else:
            print("The door is at unknow state")

        sleep(1)  # What we do we will always sleep at the end

        # ------------------------------------------------------------------------
        # End of loop

当变量值更改时,仅一次在Python上触发事件

吝吻 2025-02-19 10:14:44

任务可能希望您使用功能指针。在此中,可以在某些情况下推导打印的参数类型。请注意,如果您要同时修改和非修改功能(=函数为const引用)工作,则需要对模板的模板参数进行签名,该签名可能匹配这两种模板,例如您的增量模板。

template <typename T >
void increment(T& t)
{
    t += 1;
}

template <typename T>
void iterate(T* arr, size_t size, void (*f)(const T&)) {
    for (size_t i = 0; i < size; i++) f(arr[i]);
}

template <typename T>
void    iterate(T* arr, size_t size, void(*f)(T&)) {
    for (size_t i = 0; i < size; i++) f(arr[i]);
}

template <typename T >
void    print(const T& t) { std::cout << t << " "; };


int main(void) {
    int tab[] = { 0,1,2,3,4 };
    iterate(tab, 5, increment<int>); // not possible to deduce the template parameter for increment here (both const int and int would be signatures matching an overload of iterate)
    iterate(tab, 5, print); // template parameter of print deduced as int
}

The task may be expecting you to use function pointers. In this the parameter type of print can be deduced in some scenarios. Note that if you want both modifying and non-modifying functions (=functions taking a reference to const) to work, you need to pecify the template parameter for templates with a signature that could match both, e.g. your increment template.

template <typename T >
void increment(T& t)
{
    t += 1;
}

template <typename T>
void iterate(T* arr, size_t size, void (*f)(const T&)) {
    for (size_t i = 0; i < size; i++) f(arr[i]);
}

template <typename T>
void    iterate(T* arr, size_t size, void(*f)(T&)) {
    for (size_t i = 0; i < size; i++) f(arr[i]);
}

template <typename T >
void    print(const T& t) { std::cout << t << " "; };


int main(void) {
    int tab[] = { 0,1,2,3,4 };
    iterate(tab, 5, increment<int>); // not possible to deduce the template parameter for increment here (both const int and int would be signatures matching an overload of iterate)
    iterate(tab, 5, print); // template parameter of print deduced as int
}

将模板函数作为参数而没有实例化?

吝吻 2025-02-18 21:20:41

对于初学者,该函数具有返回类型 int ,但没有返回。另外,第二个参数应具有未签名的整数类型 size_t ,而不是签名的整数类型 int

另外,您应该在使用它们的最小范围中声明变量。

循环的主体

for (i = size - 1; i <= 0; i--) {

代码的主要问题是,如果 size 不小于 2 ,则

将永远不会得到控制。另外,还有一个错别字,

a[j] = a[i];

您必须

a[j] = swap;

分开写入此类错字。

该功能可以在以下方式查看

void selection_sort( int *a, size_t n ) 
{
    for ( size_t i = n; i-- != 0; ) 
    {
        size_t max = i;

        for ( size_t j = 0; j < i; j++ ) 
        {
            if ( a[max] < a[j] ) max = j;
        }

        if ( max != i )
        {
            int swap = a[max];
            a[max] = a[i];
            a[i] = swap;
        } 
    }
}

以下方式是一个演示程序。

#include <stdio.h>

void selection_sort( int *a, size_t n ) 
{
    for ( size_t i = n; i-- != 0; ) 
    {
        size_t max = i;

        for ( size_t j = 0; j < i; j++ ) 
        {
            if ( a[max] < a[j] ) max = j;
        }

        if ( max != i )
        {
            int swap = a[max];
            a[max] = a[i];
            a[i] = swap;
        } 
    }
}

int main( void )
{
    int a[] = { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
    const size_t N = sizeof( a ) /sizeof( *a );

    for ( size_t i = 0; i < N; i++ )
    {
        printf( "%d ", a[i] );
    }
    putchar( '\n' );

    selection_sort( a, N );

    for ( size_t i = 0; i < N; i++ )
    {
        printf( "%d ", a[i] );
    }
    putchar( '\n' );
}

它的输出是

9 8 7 6 5 4 3 2 1 0 
0 1 2 3 4 5 6 7 8 9 

For starters the function has the return type int but returns nothing. Also the second parameter should have the unsigned integer type size_t instead of the signed integer type int.

Also you should declare variables in minimum scopes where they are used.

The main problem with your code is that the body of this for loop

for (i = size - 1; i <= 0; i--) {

will never get the control provided that size is not less than 2.

Also there is a typo

a[j] = a[i];

You have to write

a[j] = swap;

Apart from this there are redundant swaps.

The function can look the following way

void selection_sort( int *a, size_t n ) 
{
    for ( size_t i = n; i-- != 0; ) 
    {
        size_t max = i;

        for ( size_t j = 0; j < i; j++ ) 
        {
            if ( a[max] < a[j] ) max = j;
        }

        if ( max != i )
        {
            int swap = a[max];
            a[max] = a[i];
            a[i] = swap;
        } 
    }
}

Here is a demonstration program.

#include <stdio.h>

void selection_sort( int *a, size_t n ) 
{
    for ( size_t i = n; i-- != 0; ) 
    {
        size_t max = i;

        for ( size_t j = 0; j < i; j++ ) 
        {
            if ( a[max] < a[j] ) max = j;
        }

        if ( max != i )
        {
            int swap = a[max];
            a[max] = a[i];
            a[i] = swap;
        } 
    }
}

int main( void )
{
    int a[] = { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
    const size_t N = sizeof( a ) /sizeof( *a );

    for ( size_t i = 0; i < N; i++ )
    {
        printf( "%d ", a[i] );
    }
    putchar( '\n' );

    selection_sort( a, N );

    for ( size_t i = 0; i < N; i++ )
    {
        printf( "%d ", a[i] );
    }
    putchar( '\n' );
}

Its output is

9 8 7 6 5 4 3 2 1 0 
0 1 2 3 4 5 6 7 8 9 

选择排序的逻辑中的错误是什么

吝吻 2025-02-18 10:15:05

正如您正确说明的那样,产品位置是两个不同的聚合。他们不能互相控制,并且拥有 product 保留对单个位置的引用没有问题。在位置中,持有 products 的列表(甚至简单的计数器)也是如此。

现在,假设您担心演示层(例如A UI甚至API),例如,由于可能更改位置 ,或删除产品。在这种情况下,您可能需要考虑派遣域事件并编写适当的处理程序来处理它们。您可能还需要考虑使用CQR,并创建/刷新查询模型将被演示层消费。

As you have correctly stated, Product and Location are two distinct aggregates. They don't control each other, and there is no problem in having Product holding a reference to a single Location. The same goes for holding a list (or even a simple counter) of Products inside a Location.

Now, suppose you are concerned about the Presentation Layer (eg. a UI or even an API), for example, due to potential changes to a Location, or deletion of a Product. In that case, you might want to consider dispatching Domain Events and write the appropriate handlers to deal with them. You might also want to consider using CQRS, and create/refresh Query Models that will be consumed by the Presentation Layer.

如何在DDD中对此情况进行建模?

吝吻 2025-02-17 20:12:34

这是一个系统问题。重新启动后,它像往常一样再次工作。

It's been a system problem. After rebooting, it worked again as usual.

watchpack错误(观察者):错误:emfile:太多的打开文件,观看&#x27;/&#x27;

吝吻 2025-02-17 16:46:06

您无法使用 is_integer ,但对于Varchar(16777216),它不支持

,因此正则表达式会更好

INSERT INTO DB.table_b 
    SELECT
        CASE 
            WHEN regexp_like(emp,'^[0-9]+
) THEN emp
            ELSE NULL  
        END AS emp_no 
    FROM
        DB.table_a;

you can not use IS_INTEGER but for VARCHAR(16777216) it isn't supported

So a regular expression would be better

INSERT INTO DB.table_b 
    SELECT
        CASE 
            WHEN regexp_like(emp,'^[0-9]+
) THEN emp
            ELSE NULL  
        END AS emp_no 
    FROM
        DB.table_a;

雪花:在数字类型列中插入零值

吝吻 2025-02-17 07:09:40

这里的问题似乎是实现 Promise.resolve()函数。任何实施打字的人都不希望将类型推断出尽可能狭窄。

const c = await Promise.resolve("test")
//    ^? c: string

如您所见,当调用 Promise.resolve()使用字符串字面的字体时,该类型被宽扩大到 string

有趣的是,在给变量的显式类型时,这不会发生。

const d: "test" = await Promise.resolve("test")
//    ^? d: "test"

这种行为似乎在版本3.5上发生了变化,但我仍在寻找解释此功能的变形值。


那么您有什么选择?

  1. 当使用 Promise.resolve()时,请使用作为const
const [a1] = await Promise.all([Promise.resolve('test' as const)])
//     ^? a1: "test"
  1. 您可以为 Promise.resolve()编写自己的包装功能,该功能尊重狭窄类型。
type Every =
  | null
  | string
  | number
  | boolean
  | Array<Every>
  | object
  | symbol
  | undefined
  | {
      [prop: string]: Every
    }

function PromiseResolve<T extends Every>(p: T): Promise<T> {
  return Promise.resolve(p)
}


const [a2] = await Promise.all([PromiseResolve('test')])
//     ^? a2: "test"

Playground

The issue here seems to be the implementation of the Promise.resolve() function. Whoever implemented the typing did not want types to be inferred as narrow as they could be.

const c = await Promise.resolve("test")
//    ^? c: string

As you can see, when calling Promise.resolve() with a string literal, the type is widened to string.

Interestingly, this does not happen when giving an explicit type to the variable.

const d: "test" = await Promise.resolve("test")
//    ^? d: "test"

This behaviour seemed to change in version 3.5 but I am still looking for the changelog which explains this feature.


So what are your options?

  1. Use as const when using Promise.resolve().
const [a1] = await Promise.all([Promise.resolve('test' as const)])
//     ^? a1: "test"
  1. You could write your own wrapper function for Promise.resolve() which respects narrow types.
type Every =
  | null
  | string
  | number
  | boolean
  | Array<Every>
  | object
  | symbol
  | undefined
  | {
      [prop: string]: Every
    }

function PromiseResolve<T extends Every>(p: T): Promise<T> {
  return Promise.resolve(p)
}


const [a2] = await Promise.all([PromiseResolve('test')])
//     ^? a2: "test"

Playground

typescript不推断promise.all()推断类型

吝吻 2025-02-17 00:26:09

看来我可以使用 min max range> range 参数,

range([list.cur_page - 2, 2] | max, ...)

所以我有:

{% if list.pages > 1 %}
  <ul class="pagination float-start flex-wrap ms-5">
    {{ render_button(list, 1) }}
    {% for p in range([list.cur_page - 2, 2] | max, [list.cur_page + 3, list.pages - 1] | min ) %}
    {{ render_button(list, p) }}
    {% endfor %}
    {{ render_button(list, list.pages) }}
  </ul>
{% endif %}

It seems I can use min and max filters in range parameters,

range([list.cur_page - 2, 2] | max, ...)

so I have:

{% if list.pages > 1 %}
  <ul class="pagination float-start flex-wrap ms-5">
    {{ render_button(list, 1) }}
    {% for p in range([list.cur_page - 2, 2] | max, [list.cur_page + 3, list.pages - 1] | min ) %}
    {{ render_button(list, p) }}
    {% endfor %}
    {{ render_button(list, list.pages) }}
  </ul>
{% endif %}

Jinja:如何获得两个值的最大值

吝吻 2025-02-16 08:31:19

将关联映射为急切通常是代码气味。但是,如果您有始终需要加载关联的情况,则可以通过查询进行。

您将致电:

@Repository
public interface ScoringRepository extends GenericRepository<ScoringEntity, String> {

    @Query("select se from ScoringEntity se left fetch join se.contributions")
    Page<ScoringEntity> findScoringWithContributions(Pageable pageable);

}

此外,我无法想象反应流与冬眠和懒惰的负载不相容。

在这种情况下,问题在于,您正在尝试在会话关闭后懒惰加载关联。

Mapping the association as EAGER is usually a code smell. But if you have situations where you always need to load an association, you can do it via a query.

Instead of findAll, you would call:

@Repository
public interface ScoringRepository extends GenericRepository<ScoringEntity, String> {

    @Query("select se from ScoringEntity se left fetch join se.contributions")
    Page<ScoringEntity> findScoringWithContributions(Pageable pageable);

}

Besides I can't imagine that reactive streams be incompatible with hibernate and lazy loading.

In this case the problem is that you are trying to lazy load the association after the session has been closed.

如何使用冬眠的懒惰加载和反应流?

吝吻 2025-02-16 00:47:12

Prisma的MongoDB连接器不支持 autoincrement() autoincrement()仅由关系数据库连接器支持。请参阅Prisma docs >解释了这一点。
您还可以查看与此主题相关的先前讨论在这里

MongoDB connector for prisma doesn't support autoincrement(). autoincrement() is only supported by the relational database connectors. See the Prisma docs that explains this.
You can also view a previous discussion related to this topic here

使用MongoDB在Prisma上创建自动增量ID的正确方法

吝吻 2025-02-15 19:30:25

您可以使用控制器无需身份验证就可以做到这一点,然后像Odoo一样返回PDF,但使用Sudo Enviroment。

请显示一些代码以正确帮助您。

You can do it using controllers without authentication, and then return a PDF like Odoo does but using sudo enviroment.

Please show some code to help you properly.

ODOO 14公共URL用于未经身份验证的PDF文件打开

吝吻 2025-02-15 15:58:04

您可以这样做:

class Person with ChangeNotifier {
  Person({this.name, this.age});

  final String name;
  int age;

  void increaseAge() {
    this.age++;
    notifyListeners();
  }
}

// here, you can see that the [ChangeNotifierProvider]
// is "wired up" exactly like the vanilla [Provider]
void main() {
  runApp(
    ChangeNotifierProvider(
      create: (_) => Person(name: "Yohan", age: 25),
      child: MyApp(),
    ),
  );
}

You can do Like This:

class Person with ChangeNotifier {
  Person({this.name, this.age});

  final String name;
  int age;

  void increaseAge() {
    this.age++;
    notifyListeners();
  }
}

// here, you can see that the [ChangeNotifierProvider]
// is "wired up" exactly like the vanilla [Provider]
void main() {
  runApp(
    ChangeNotifierProvider(
      create: (_) => Person(name: "Yohan", age: 25),
      child: MyApp(),
    ),
  );
}

&#x27;更改Notifier提供商&#x27; ISN&#x27; ta功能错误消息

吝吻 2025-02-15 10:03:11

当Aurelia看到元素时,就会创建一个Todolist的实例。当您将其“新”起来时,您已经创建了一个单独的实例。您应该使用view-model.ref捕获对Aurelia创建的实例的引用,而不是创建Todolist类的新实例。

app.html

<template>
  <require from="./todo-list"></require>
  <h1>Todo list</h1>
  <form submit.trigger="addTodo()">
    <input type="text" value.bind="todoDescription">
    <button type="submit" disabled.bind="!todoDescription">Add Todo</button>
  </form>
  <todo-list view-model.ref="todoList"></todo-list>
</template>

app.ts

import { TodoList } from "todo-list";
export class App {
  todoList: TodoList;
  todoDescription = '';

  addTodo() {
    if (this.todoDescription) {
      this.todoList.addOne(this.todoDescription);
      this.todoDescription = '';
    }
  }
}

Aurelia creates an instance of TodoList when it sees the element. You have created a separate instance when you "newed" it up. Instead of creating a new instance of the TodoList class, you should use view-model.ref to capture a reference to the instance aurelia has created.

app.html

<template>
  <require from="./todo-list"></require>
  <h1>Todo list</h1>
  <form submit.trigger="addTodo()">
    <input type="text" value.bind="todoDescription">
    <button type="submit" disabled.bind="!todoDescription">Add Todo</button>
  </form>
  <todo-list view-model.ref="todoList"></todo-list>
</template>

app.ts

import { TodoList } from "todo-list";
export class App {
  todoList: TodoList;
  todoDescription = '';

  addTodo() {
    if (this.todoDescription) {
      this.todoList.addOne(this.todoDescription);
      this.todoDescription = '';
    }
  }
}

从Aurelia中的父部件中更新可观察的收藏

吝吻 2025-02-14 23:00:52

在这里远非铁路专家,但我已经看到涡轮增压表提交了422:Unprocessable_entity的回复,然后立即获得响应200的起始URL。它是令人难以置信的无证Afaik。我在这里要求提供官方文档帮助:

https://discuss.rubyonrails.org/t/do-we-we-need-need-rails-rails-7-7-7-guides-for-for--------------7-guides-for-intergrating-with-turbo--turbo--turbo--turbo--turbo--turbo--turbo----------- to-Counter-stackoverflow-cruft/83635

当涡轮在响应中找不到完整的DOM时,就会发生 它发生。它无法比较您所拥有的东西,因此只会踩踏422并获得。我已经看到这种情况在两种情况下发生:呈现部分而不是呈现完整的响应,或者从没有布局的控制器呈现。

原因1:渲染部分而不是完全渲染

以下内容会导致惊喜获得200,使您的422 Unrprocessable_entity踩踏:

# with app/views/_book.html.haml
render partial: 'book'
return
render partial: 'book', status: :unprocessable_entity
return

惊喜!您可能会认为涡轮的魔力将能够整齐地识别您的部分替代品,但不能。您可能会认为这会引起例外,但事实并非如此。

另一方面,这将起作用:

# app/views/book.html.haml
render 'book', status: :unprocessable_entity

现在,您正在呼吁进行完整的响应和422杆。

文档描述渲染是一个完整的响应:

原因2:使用没有布局的控制器

,有一种选择布局的方法,而轨道显然可以选择没有布局或错误的布局。

如果您没有“ more_different_book”布局:

# controllers/more_different_book_controller.rb
# no layout called for
def do_stuff
  ...
  return render 'book', status: :unprocessable_entity
end

获得200!

但是,添加明确的(现有)布局可以神奇地修复它:

# controllers/more_different_book_controller.rb
layout 'book'
def do_stuff
  ...
  return render 'book', status: :unprocessable_entity
end

我可能会误解原因,但这是我观察到的以及如何超越它。

Far from a Rails expert here, but I have seen a Turbo form submit, get a response of 422 :unprocessable_entity and then immediately GET the starting url with response 200. It's maddeningly undocumented afaik. I've asked for official documentation help here:

https://discuss.rubyonrails.org/t/do-we-need-official-rails-7-guides-for-integrating-with-turbo-to-counter-stackoverflow-cruft/83635

It happens when Turbo cannot find a complete DOM in the response. It can't compare what you have to what you're getting and so it just stomps the 422 and GETs. I have seen this happen in two circumstances: rendering a partial instead of rendering a complete response, or rendering from a controller without a layout.

Cause 1: Rendering a partial instead of fully rendering

The following will result in a surprise GET 200 that stomps your 422 unprocessable_entity:

# with app/views/_book.html.haml
render partial: 'book'
return
render partial: 'book', status: :unprocessable_entity
return

Surprise! You would think the magic of Turbo would be able to neatly identify your partial for replacement, but it cannot. You'd think it would raise an exception, but it does not.

This on the other hand will work:

# app/views/book.html.haml
render 'book', status: :unprocessable_entity

Now you're calling for a complete response and the 422 sticks.

Documentation describing render as a complete response:

https://guides.rubyonrails.org/layouts_and_rendering.html#creating-responses

Cause 2: Using a controller without a layout

There's a method for selecting your layout and Rails can select no layout or the wrong layout, apparently.

https://guides.rubyonrails.org/layouts_and_rendering.html#finding-layouts

This could be wrong if you don't have a "more_different_book" layout:

# controllers/more_different_book_controller.rb
# no layout called for
def do_stuff
  ...
  return render 'book', status: :unprocessable_entity
end

GET 200!

But adding an explicit (existing) layout could magically fix it:

# controllers/more_different_book_controller.rb
layout 'book'
def do_stuff
  ...
  return render 'book', status: :unprocessable_entity
end

I could be misunderstanding the cause, but this is what I have observed and how I moved past it.

Rails 7&#x2B; Turbo:收到422个无法取得的实体时,Turbo会导航

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文