Ruby on rails 使用Postman rest api[RAILS 4]创建对象时出错

Ruby on rails 使用Postman rest api[RAILS 4]创建对象时出错,ruby-on-rails,ruby-on-rails-4,Ruby On Rails,Ruby On Rails 4,我试图使用Postman REST API创建rails应用程序的对象,但出现以下错误: ActionController::ParameterMissing in GroupsController#create 我的控制器: class GroupsController < ApplicationController before_action :set_group, only: [:show] skip_before_filter :verify_authenticity_token

我试图使用Postman REST API创建rails应用程序的对象,但出现以下错误:

ActionController::ParameterMissing in GroupsController#create
我的控制器:

class GroupsController < ApplicationController
before_action :set_group, only: [:show]
skip_before_filter :verify_authenticity_token

def show
    render json: @group 
end

def new
    @group = Group.new
end

def create
    @group = Group.new(group_params)
    if @group.save
            render json: @group
            else
        render json: @group.errors
    end
end

private
def set_group
    @group = Group.find(params[:id])
end
def group_params
    params.require(:group).permit(:title, :description, :user_id)
end

end
但现在它说这些字段即使存在也不能为空。我是否发送了错误的参数[:组]

日志文件:

Started POST "/groups" for 127.0.0.1 at 2014-03-14 22:21:26 +0100
Processing by GroupsController#create as */*
[1m[35m (0.1ms)[0m  begin transaction
[1m[36m (0.1ms)[0m  [1mrollback transaction[0m
Completed 200 OK in 7ms (Views: 0.3ms | ActiveRecord: 0.2ms)

您可以尝试使用以下json负载

{
    'group' : {
    'title': 'your title',
    'description': 'your description',
    'user_id': 1
    }
}
并在标题中设置
内容类型:application/json

另外,在url中将请求格式设置为.json

您的参数需要采用属于
组的属性的形式,这是本例中的模型。要在Postman中实现这一点,请使用URL参数而不是原始参数,以使您的生活更轻松。以下是一个屏幕截图:


另外,如果您希望通过json执行上述一个答案,请确保将post请求从
http://0.0.0.0:3000/groups
http://0.0.0.0:3000/groups.json

邮差中参数的名称是“组”而不是“组”。仍然不工作。我想错误来自控制器。无论如何,在邮递员我有如图片,但我想它应该是insteadNaren,请检查我的最新更新!是的,应该是团体。另外,
fetch
方法返回空散列(作为第二个参数传递)。Rails无法解析通过postman发送的参数。尝试在标题中设置内容类型,或通过在url中添加.xml来设置请求格式。还有一点,您在标题中提到了JSON,并在示例中使用了xml请求!!我这样做了,但仍然不起作用,我认为我在使用强参数方面存在问题,并且数据也没有发送到控制器。您是否也可以添加有问题的请求日志。对不起,Naren,您通过请求日志来查询什么?请根据您的环境查看development/production.log文件。当你发布一个请求时,在日志文件中输入请求条目啊,是的,我复制了我的请求所创建的内容。
{
    'group' : {
    'title': 'your title',
    'description': 'your description',
    'user_id': 1
    }
}