現在,此控制器中的此操作由遠程ajax調用調用。
只有當複選框[:call]被選中並提交時,
我想使它重定向到......_路徑並顯示flash消息。當被遠程ajax調用時是否可以使用redirect_to?
可能嗎?如果可能的話,如何?
控制器
.....
if params[:comment][:call] == "1"
flash[:notice] = "you checked and submit!"
redirect_to ....._path
else
ajax page reload
end
視圖表格(遠程使用Ajax)
<%=form_for(([@community, @comment]), :remote => true, :class => 'form') do |f| %>
<%= f.check_box :call, :label => 'call' %> call
<div class="form-actions">
<div class="input-append">
<%= f.text_field :body, :id => "input", :class => "box" %>
<button type="submit" class="btn">submit</button>
</div>
</div>
<% end %>
Comment模型
attr_accessible :icon, :call
....
def call
@call ||= "0"
end
def call=(value)
@call = value
end
非常感謝。這是我想要的完美答案:) – cat