Ruby on rails 如何在另一个视图中添加带有回形针字段的表单?
因此,正如标题所示,我在这里试图完成的事情相当简单。我需要在控制器的Ruby on rails 如何在另一个视图中添加带有回形针字段的表单?,ruby-on-rails,paperclip,Ruby On Rails,Paperclip,因此,正如标题所示,我在这里试图完成的事情相当简单。我需要在控制器的show视图中生成一个from。我有一个设计生成用户,我想有一个标题图像。但是,我不想将header\u img字段添加到designe表单中,我只想让它自己出现在我的视图中。最终,我希望它在我的视图上点击一个“编辑”按钮,它将显示表单。类似于twitter的做法。现在我得到一个未定义的局部变量或方法用户\u路径错误。我已经按照github上关于回形针的文档进行了操作,我不确定出了什么问题 我的节目视图 我的用户模型 cla
show
视图中生成一个from。我有一个设计生成用户,我想有一个标题图像。但是,我不想将header\u img
字段添加到designe表单中,我只想让它自己出现在我的视图中。最终,我希望它在我的视图上点击一个“编辑”按钮,它将显示表单。类似于twitter的做法。现在我得到一个未定义的局部变量或方法用户\u路径错误
。我已经按照github上关于回形针的文档进行了操作,我不确定出了什么问题
我的节目视图
我的用户模型
class User < ActiveRecord::Base
#this is for the business header img
has_attached_file :header_img, styles: { large: "1200x500>" }, default_url: "/images/:style/missing.png"
validates_attachment_content_type :header_img, content_type: /\Aimage\/.*\Z/
end
class用户”},默认url:“/images/:style/missing.png”
验证\u附件\u内容\u类型:标题\u img,内容\u类型:/\Aimage\/.\Z/
结束
您的问题与在其他视图中使用回形针字段无关。
只有在声明资源路由时,您尝试使用的帮助程序users\u path
才可用
来自导轨的导轨()
创建一个资源丰富的路由还将向应用程序中的控制器公开许多帮助程序。对于资源:照片:
必须检查是否为用户模型声明了资源路由
希望这有帮助
class User < ActiveRecord::Base
#this is for the business header img
has_attached_file :header_img, styles: { large: "1200x500>" }, default_url: "/images/:style/missing.png"
validates_attachment_content_type :header_img, content_type: /\Aimage\/.*\Z/
end
photos_path returns /photos
new_photo_path returns /photos/new
edit_photo_path(:id) returns /photos/:id/edit (for instance, edit_photo_path(10) returns /photos/10/edit)
photo_path(:id) returns /photos/:id (for instance, photo_path(10) returns /photos/10)