[英]Why do i not see my Ajax update on my webpage with refreshing the page?
为什么即使我在form_with
的ruby中使用form_with
,我的网页也无法通过Ajax进行自我更新? 我想念什么? 如果您需要发布更多信息以帮助您,请告诉我。
Started GET "/artists/1" for 127.0.0.1 at 2017-10-28 15:45:54 +0200
Processing by ArtistsController#show as JS
Parameters: {"id"=>"1"}
Artist Load (0.2ms) SELECT "artists".* FROM "artists" WHERE
"artists"."id" = $1 LIMIT $2 [["id", 1], ["LIMIT", 1]]
Rendering artists/show.html.erb within layouts/application
Photo Load (0.2ms) SELECT "photos".* FROM "photos" WHERE
"photos"."artist_id" = $1 [["artist_id", 1]]
Song Load (0.2ms) SELECT "songs".* FROM "songs" WHERE
"songs"."artist_id" = $1 [["artist_id", 1]]
Rendered collection of songs/_song.html.erb [4 times] (3.6ms)
Rendered songs/_form.html.erb (3.3ms)
Rendered artists/show.html.erb within layouts/application (60.5ms)
Completed 200 OK in 154ms (Views: 133.6ms | ActiveRecord: 0.7ms)
songscontroller:
class SongsController < ApplicationController
def create
@artist = Artist.find(params[:artist_id])
@song = @artist.songs.create(song_params)
redirect_to artist_path(@artist)
end
end
<%= form_with(model: [ @artist, @artist.songs.build ]) do |form| %>
<p>
<%= form.text_field :name %>
</p>
<p>
<%= form.submit %>
</p>
<% end %>
您的pague不会刷新,因为get方法在您的show action中作为JS处理,并且应该为html或*/*
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.