如何用简单的形式定义动作? [英] How to define action with simple form for?

查看:35
本文介绍了如何用简单的形式定义动作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 admin/photographers 控制器中定义操作savenew".

I am trying to define the action "savenew" in admin/photographers controller.

我已经试过了:

<%= simple_form_for(:photographer_savenew, :action => 'savenew', :id  => params[:id],  :multipart => true ) do |f| %>

但是表单中的action还是:/admin/photographers

But the action in the form is still: /admin/photographers

什么时候应该:/admin/photographers/savenew

推荐答案

您不使用 REST 的原因是什么?它会让你的生活更轻松,并且需要更少的代码.如果您准备使用此自定义操作,则需要指定 url 以及可能的方法:

Is there a reason you're not using REST for this? It would make your life a lot easier and requires much less code. If you're set on using this custom action, you will need to specify the url and probably the method:

<%= simple_form_for @photographer, :url => savenew_photographers_path, :method => :post ... # etc

这篇关于如何用简单的形式定义动作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆