小编ste*_*opo的帖子

M.Hartl的Rails教程7.4.1中的参数数量错误(2个为1)错误

我一直在关注最新版本的M.Hartl的Rails教程,我在第7.4.1章遇到了一个问题.我创建了一个与用户控制器的新操作相关联的注册表单.当表单提交有效信息时,控制器应重定向到新用户配置文件,但是我在下面发生错误...

我已经包含了routes.rb代码以及Users控制器代码.谁能帮助我?

当我访问url .. / users/1时,页面实际上呈现了我的用户,因此我知道用户已经创建并保存到数据库中.我不知道是否可能是redirect_to方法的实现错误?

任何帮助将不胜感激!


UsersController中的ArgumentError#创建错误的参数个数(2个为1)

提取的来源(第19行):

private
  def _compute_redirect_to_location_with_xhr_referer(options)
    store_for_turbolinks begin
      if options == :back && request.headers["X-XHR-Referer"]
        _compute_redirect_to_location_without_xhr_referer(request.headers["X-XHR-Referer"])
Run Code Online (Sandbox Code Playgroud)

用户控制器:

class UsersController < ApplicationController

  def new
    @user = User.new
  end

  def show
    @user = User.find(params[:id])
  end

  def create
    @user = User.new(user_params)  
    if @user.save
      flash[:success] = "Welcome to the Sample App!"
      redirect_to @user
    else
      render 'new'
    end
  end

  private 

    def user_params
      params.require(:user).permit(:name, :email, :password, :password_confirmation)
    end
end
Run Code Online (Sandbox Code Playgroud)

Routes.rb:

Rails.application.routes.draw do
  root             'static_pages#home'
  get 'help'    => 'static_pages#help' …
Run Code Online (Sandbox Code Playgroud)

ruby ruby-on-rails railstutorial.org

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

如何使用 react-google-maps 禁用街景?

我正在使用react-google-maps包在我的反应应用程序中呈现 Google 地图。我想禁用街景。

文档中,我看到有以下道具:

  • 默认街景

  • 街景

我曾尝试将两者与 false 一起使用 - 但都不起作用。有谁知道如何通过这个包禁用街景功能?

代码片段在这里:

import React, { Component } from 'react';
import { withScriptjs, withGoogleMap, GoogleMap, Marker } from "react-google-maps";
import PropTypes from 'prop-types';

const Map = withScriptjs(withGoogleMap((props) => {
    return(
        <GoogleMap 
            defaultZoom={17}
            defaultCenter={{ lat: props.lat, lng: props.lng }}
            // defaultStreetView={false}
            // streetView={false}
        >
            {props.isMarkerShown && <Marker position={{ lat: props.lat, lng: props.lng }} />}
        </GoogleMap>
    )
}))

Map.propTypes = {
    lat: PropTypes.number.isRequired,
    lng: PropTypes.number.isRequired,
    isMarkerShown: PropTypes.bool.isRequired
}

export …
Run Code Online (Sandbox Code Playgroud)

reactjs react-google-maps

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