我正在使用Gmaps4rails API。但每当我更新或编辑地址时,gmaps4rails仍指向旧地址。我是rails的新手,所以不确定是什么错误。
以下是我的Controller.rb文件
def show
if current_user.Company.nil?
@estate = current_user.estates.find(params[:id])
else
@estate = Estate.find(params[:id])
end
respond_to do |format|
format.html # show.html.erb
format.json { render json: @estate }
end
end
def new
@@key = params[:user_id]
@master = @@key
@estate = Estate.new
@json = @estate.all.to_gmaps4rails
respond_to do |format|
format.html # new.html.erb
format.json { render json: @estate }
end
end
def edit
@estate = Estate.find(params[:id])
@json = @estate.to_gmaps4rails
end
def create
# @estate = Estate.new(params[:estate])
if current_user.Company.nil?
@estate = current_user.estates.build(params[:estate])
else
serve = User.find(@@key)
@estate = Estate.new(params[:estate])
@estate.user_id = serve.id
@estate.Mgmt = current_user.Company
end
respond_to do |format|
if @estate.save
if current_user.Company.nil?
if @estate.companyemail = ''
##
else
EstateMailer.company_confirmation(@estate).deliver
end
end
format.html { redirect_to @estate, notice: 'Property details were successfully updated.' }
format.json { render json: @estate, status: :created, location: @estate }
else
format.html { render action: "new" }
format.json { render json: @estate.errors, status: :unprocessable_entity }
end
end
end
def update
@estate = Estate.find(params[:id])
@json = Estate.all.to_gmaps4rails
respond_to do |format|
if @estate.update_attributes(params[:estate])
format.html { redirect_to @estate, notice: 'Property details were successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @estate.errors, status: :unprocessable_entity }
end
end
end