我有2个型号的财产和财产日期。 我需要在属性日期表中保存属性的多个开始日期和结束日期 表字段(property_id,start_date_end_date) 我的模型表
`class Property < ActiveRecord::Base
has_many :property_dates
accepts_nested_attributes_for :property_dates
end`
`class PropertyDate < ActiveRecord::Base
belongs_to :property
end`
class Users::PropertiesController < ApplicationController
before_filter :authenticate_user!
before_action :set_properties, only: [:show, :edit, :update, :destroy]
def index
@properties = Property.where(:user_id=>current_user.id)
end
def list
@properties = Property.all
end
def show
end
def new
@property= Property.new
end
def edit
end
def create
@property = Property.new(properties_params)
respond_to do |format|
if @property.save
format.json { render :index, status: :created, location: @property }
else
format.html { render :new }
format.json { render json: @property.errors, status: :unprocessable_entity }
end
end
end
def update
respond_to do |format|
if @property.update(properties_params)
format.json { render :back, status: :ok, location: @property }
else
format.json { render json: @property.errors, status: :unprocessable_entity }
end
end
end
def destroy
@property.destroy
respond_to do |format|
format.html { redirect_to :back, notice: 'Property was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_properties
@property = Property.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def properties_params
params.require(:property).permit(:Space_name,:user_id,:address,:pincode,:image,property_dates_attributes: [ :start_date, :end_date ])
表单属性表单我需要选择多个日期并需要保存到property_dates表
my form.html.erb
`<%= simple_nested_form_for ([:users,@property]) do |f| %>
<%= f.fields_for :property_dates do |p| %>
<%= p.text_field :start_date%>
<%= p.text_field :end_date%>
<% end %>
<% end %>`
当我写表单时,它在我的表单中不可见。为什么会这样?我的代码中有任何错误。请帮忙。
答案 0 :(得分:0)
只需改变它:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="UDPProxy"
transports="udp"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<log level="full"/>
<property name="OUT_ONLY" value="true"/>
</inSequence>
<endpoint>
<address uri="http://127.0.0.1:9764"/>
</endpoint>
</target>
<parameter name="transport.udp.port">9998</parameter>
<parameter name="transport.udp.contentType">text/xml</parameter>
<description/>
</proxy>