となります。rails 3 button_to:remote => true、コントローラアクションの外観は
私は何をしているのかわからないので、私はajax reqsの新人です。私が理解しているように、:remote => trueはそれをajaxリクエストに設定します。
<%= button_to "Generate Code", add_code_band_path(@band), :method => :post, :remote => true %>
私の現在の行動:
def add_code
@band = Band.find(params[:id])
if user_signed_in?
@code = current_user.codes.build(params[:code])
respond_to do |format|
if @code.save
format.html { redirect_to @band, notice: 'Reward was successfully created.' }
format.json { render json: @band, status: :created, location: @band }
else
format.html { render action: "show" }
format.json { render json: @band.errors, status: :unprocessable_entity }
end
end
else
redirect_to @band, :alert => "Your Not Logged In! You must be logged in to create a code"
end
end
どのようなエラーが表示されますか? –
エラーはありませんが、画面が更新されます。 –