小编Ran*_*inn的帖子

Rails 6 - 常量 ActionController::InvalidAuthenticityToken

我正在修改 Rails 6 并且我不断在由 rails 生成的表单上获取 ActionController::InvalidAuthenticityToken,例如(实现 rails 教程书籍注册/登录流程)

<%= form_for(@user, url: 'signup') do |f| %>
     <%= render 'partials/error_messages' %>
     <%= f.label :name, "Nimi" %>
     <%= f.text_field :name %>
     <%= f.label :email, "E-mail" %>
     <%= f.email_field :email %>
     <%= f.label :password, "Parool" %>
     <%= f.password_field :password %>
     <%= f.label :password_confirmation, "Korda parooli" %>
     <%= f.password_field :password_confirmation %>
     <%= f.submit "Loo konto", class: "button-green" %>
<% end %>
Run Code Online (Sandbox Code Playgroud)

这发生在所有形式上,输出转储看起来像这样

转储

应用程序.html.erb

<!DOCTYPE html>
<html>
  <head>
    <title>Storebase - kaasaegsed e-poed!</title>
    <%= csrf_meta_tags %> …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails csrf actioncontroller authenticity-token ruby-on-rails-6

9
推荐指数
1
解决办法
4195
查看次数

JSPM Angular2-rc2构建动画错误

因此,使用JSPM构建我的angular2项目以进行发布:jspm bundle-sfx app dist/main.sfx.js.一切都很好,直到我尝试在浏览器中加载构建的应用程序.这是我得到的错误:`

EXCEPTION: Error during instantiation of AnimationDriver! (ViewUtils -> RootRenderer -> DomRootRenderer -> AnimationDriver

ORIGINAL EXCEPTION: TypeError: Cannot read property 'animate' of null
Run Code Online (Sandbox Code Playgroud)

完整日志如下:

The key "target-densitydpi" is not supported.
EXCEPTION: Error during instantiation of AnimationDriver! (ViewUtils -> RootRenderer -> DomRootRenderer -> AnimationDriver).
EXCEPTION: Error during instantiation of AnimationDriver! (ViewUtils -> RootRenderer -> DomRootRenderer -> AnimationDriver).
ORIGINAL EXCEPTION: TypeError: Cannot read property 'animate' of null
ORIGINAL STACKTRACE:
TypeError: Cannot read property 'animate' of null
    at …
Run Code Online (Sandbox Code Playgroud)

jspm angular

7
推荐指数
1
解决办法
999
查看次数

PHP从存储的完整类路径字符串中获取类

我在我的数据库中存储了一个PHP类名,其名称空间为字符串.示例: "App\Fields\TextField".稍后,基于该字符串,我想读取字符串定义的类上的静态变量.我怎么能这样做?

php

4
推荐指数
1
解决办法
67
查看次数

PHP 可以轻松地将数组解构为单独的变量以传递给函数

假设我有一个像这样的 PHP 数组。

array(2) { ["page"]=> string(1) "a" ["subpage"]=> string(4) "gaga" }

我想将此数组的内容传递给函数调用,如下所示:

function doStuff($page, $subpage) {
 // Do stuff
}
Run Code Online (Sandbox Code Playgroud)

我如何将该数组解构为单个对象以传递给函数?函数的变量的顺序始终与数组中相应键的顺序相同。

php arrays

3
推荐指数
1
解决办法
2583
查看次数

Rails 阻止特定路线上的 before_action

有没有办法阻止before_action在特定路线上运行?比如说,发布执行 api 操作的路由?我的操作目前是这样做的

before_action :setContext

    def setContext
        @site = Site.find_by!(host: request.subdomain)
        @page = Page.find_by!(site_id: @site.id, slug: request.path)
    end
Run Code Online (Sandbox Code Playgroud)

在 api 路由上,页面发现 404

ruby-on-rails

1
推荐指数
1
解决办法
1732
查看次数