Activeadmin无法更改“窗体”新的标题或编辑
我在我的应用程序中使用rails 4和活动的管理宝石。 我希望在渲染或重定向到新页面或编辑页面时更改我的页面默认标题,但下面的代码不起作用。Activeadmin无法更改“窗体”新的标题或编辑
我的代码是
form :title => { :new => "New action", :edit => "Edit action"} do |f|
f.input reason, :label => "Reason", :input_html => {rows: 5}
end
但是当我使用下面的代码,它的工作
def new
@page_title = "New Action"
end
def edit
@page_title = "Edit Action"
end
但新页面上的验证的渲染后的更新不及时的标题,因为它的唯一的渲染没有进行重定向,
def create
@object = Model.new(params)
respond_to do |format|
if @object.save
flash[:notice] = 'Saved Successfully'
format.html { redirect_to collection_url }
else
format.html { render "new" }
end
end
end
如何解决这个问题,可以请任何人帮我
在create和update方法中添加@page_title工作。
验证失败后,页面标题在将其添加到创建和更新方法时也起作用。
def create
@page_title = "new title"
@object = Model.new(params)
respond_to do |format|
if @object.save
flash[:notice] = 'Saved Successfully'
format.html { redirect_to collection_url }
else
format.html { render "new" }
end
end
end
如果作品试试这个,设置
@page_title = “ACTION_TYPE”
其中验证中的其他部分入门失败即。 渲染页面将选择新的@page_title值
谢谢,它的工作原理。同时在create方法中设置@page_title也适用于我..感谢您的帮助。 – 2014-09-15 14:48:04
欢迎.... :) – bunty 2014-09-16 04:37:19
目的是什么?不太明白。请添加一些信息,说明它现在是怎样的,它应该是怎样的 – 2014-09-12 12:12:02