我有一个使用acts_as_url的模型,在我的控制器中,我想在将模型保存到“新建”后重定向到该模型。redirect_to @mymodel只是把我带到/mycontroller/1而不是/mycontroller/nice-long-url
发布于 2012-04-03 21:03:04
您需要覆盖模型中的to_param方法并使用命名路由:
# Inside your model
def to_param
url # or whatever you set :url_attribute to
endredirect_to mymodel_path(@mymodel)
https://stackoverflow.com/questions/9993664
复制相似问题