【发布时间】:2013-04-18 22:03:54
【问题描述】:
现在此控制器中的此操作由远程 ajax 调用调用。
仅当复选框[:call] 被选中并提交时,
我想让它重定向到 ......_path 与 flash 消息。
有可能吗?如果可能,怎么做?
控制器
.....
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 %>
评论模型
attr_accessible :icon, :call
....
def call
@call ||= "0"
end
def call=(value)
@call = value
end
【问题讨论】:
标签: ruby-on-rails ajax ruby-on-rails-3