ActiveModel 和路径助手
在 Rails3 应用程序中,我想对表示图像文件上传的 ActiveModel EntityImage 使用资源丰富的路径。在某个目录中,我有这些文件 dir/#{type}/#{id}/#{size}.jpg (基本上是该类的所有重要字段)
现在,可能是因为“id”是一个坏名字 Rails (这不是域明智的),当我想创建删除按钮时,我得到一个指向以下内容的表单:
<form class="button_to" action="/entity_images/test2" method="post">
<div>
<input type="hidden" value="delete" name="_method"/>
<input type="submit" value="Excluir" data-confirm="Certeza?"/>
<input type="hidden" value="4SWGCEfvdrWrj7xBBtlT0CR4EHPzXQaCFWF0/blmKCk=" name="authenticity_token"/>
</div>
</form>
当然,有了这些信息,我无法访问我的图像,我仍然需要知道实体的类型和尺寸。我怎样才能让路径助手做正确的事情?或者还有什么其他的想法、建议?
In a Rails3 app, I want to use resourceful paths for an ActiveModel EntityImage representing image file uploads. In some directory I have these files dir/#{type}/#{id}/#{size}.jpg (which are basically all important fields of that class)
Now, probably, because 'id' is a bad name rails wise (it is not domain wise), when I want to make a delete button, I get a form pointing to:
<form class="button_to" action="/entity_images/test2" method="post">
<div>
<input type="hidden" value="delete" name="_method"/>
<input type="submit" value="Excluir" data-confirm="Certeza?"/>
<input type="hidden" value="4SWGCEfvdrWrj7xBBtlT0CR4EHPzXQaCFWF0/blmKCk=" name="authenticity_token"/>
</div>
</form>
Of course, with this info, I cannot get to my image, I still need to know the type of the entity and the size. How could I make the path helpers do the right thing? Or any other idea, suggestion?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,所以我从(现在)名称、类型和大小加入了 id 属性,并且可以拆分它并重建这些值
Ok, so I joined the id property from (now) name, type and size and can split that and reconstruct these values