我的应用程序支持图像上传。如果成功,用户会收到一条成功消息:
控制器:
def create
@rating = Rating.new(params[:rating])
respond_to do |format|
if @rating.save
format.html { redirect_to @rating, :notice => 'Got It!',
:flash => {:notice_small => 'Your photo has been uploaded. good luck with its coolness rating!'} }
format.json { render :json => @rating, :status => :created, :location => @rating }
else
format.html { render :action => "new" }
format.json { render :json => @rating.errors, :status => :unprocessable_entity }
end
end
end
风景:
<br>
<br>
<div style="height: 100px;" class="visible-tablet visible-phone"></div>
<p id="notice" class="big_notice"><%= notice %></p>
<% if defined? flash[:notice_small] %>
<p id="small_notice" class="small_notice"><%= flash[:notice_small] %></p>
<% end %>
在桌面上运行良好。但不是在手机上:-(图片已上传,但我没有收到确认消息
编辑:我在移动设备上查看了源代码并像这样显示 html
<p id="notice" class="big_notice"></p>
<p id="small_notice" class="small_notice"></p>
表示flash[:notice_small]
已定义(注意if defined? flash[:notice_small]
条件)但它只是空的