您好我想通过在其他表中使用客户ID插入客户城市在一个表中插入客户名称。 我的代码只插入客户。城市没有插入
我的控制台
开始发布" / pages"对于127.0.0.1在2017-01-30 14:40:15 +0530 PagesController处理#create as HTML参数: {" UTF8" = GT;"✓&#34 ;, " authenticity_token" = GT;" NfyA8PpA4wZIAOPX7fYstwvt2suXoTYgl9ep1M6yTSh6ZPX8lt + oOfPX6sFXGOuxTidVND6qaksz6iZ2enGj9g ==&#34 ;, "客户" => {"名称" =>" fgfg"," custcity" => {" cityname&# 34; =>" 2FG"}}, "提交" =>"提交"}未经许可的参数:custcity(0.1ms)begin 事务SQL(2.3ms)INSERT INTO"客户" ("名称&#34 ;, " created_at"," updated_at")VALUES(?,?,?)[[" name"," fgfg"], [" created_at",2017-01-30 09:10:15 UTC],[" updated_at",2017-01-30 09:10:15 UTC]](231.7ms)提交事务(0.2ms)开始 事务(0.1ms)回滚事务重定向到 http://localhost:3000/pages完成302发现于247ms (ActiveRecord:234.3ms)
new.html.erb
<%= form_for @customer, url: {action: "create"} do |f| %>
<%= label_tag("Customer") %>
<br>
<%= f.text_field(:name) %>
<br>
<%= f.fields_for @custcity do |c| %>
<%= label_tag("City 1") %>
<br>
<%= c.text_field(:cityname) %>
<br>
<%= label_tag("City 2") %>
<br>
<%= c.text_field(:cityname) %>
<br>
<% end %>
<br>
<%= f.submit("submit") %>
<% end %>
pages_controller.rb
def create
@customer = Customer.new(cust_params)
if @customer.save
session[:customer_id] = @customer.id
#@custcity = Custcity.create(cityname: params[:customer][:cityname], cust_id: session[:customer_id])
@custcity = Custcity.create({cityname: params[:customer][:cityname], cust_id: @customer.id})
#@custcity.save
redirect_to pages_path
else
redirect_to new_page_path
end
end
private
def cust_params
params.require(:customer).permit(:name, :custcity => [])
end
end
答案 0 :(得分:1)
错误的 Scheduler groupScheduler = Schedulers.newParallel("groupByPool", 16);
Flux.fromStream(incomingMessages()) // stream of new data from socket
.groupBy(Message::getEntityId) // split incoming messages by groups, which should be processed serially
.map(g -> g.publishOn(groupScheduler)) //create new publisher for groups of messages
.subscribe( //create consumer for main stream
stream ->
stream.subscribe(this::processMessage) // create consumer for group stream and process messagaes
);
密钥路径。你丢失了:cityname
:custcity
允许@custcity = Custcity.create({cityname: params[:customer][:custcity][:cityname], cust_id: @customer.id})
:
cityname