【问题标题】:How can I create a form that allow user to upload new image or select from uploaded to set as profile image?如何创建允许用户上传新图像或从上传中选择设置为个人资料图像的表单?
【发布时间】:2013-10-31 15:46:36
【问题描述】:

我正在使用 carierwave 来允许我的 rails 应用程序的用户将图像上传到他们的相册。如何创建允许用户上传新图像或从上传中选择设置为个人资料图像的表单?

【问题讨论】:

    标签: ruby-on-rails ruby image upload carrierwave


    【解决方案1】:

    只需在表单中添加适当的属性即可。

    例如:

     <%= form_for @user, :html => {:multipart => true} do |f| %>
        <p>
          <label>My Avatar URL:</label>
          <%= image_tag(@user.avatar_url) if @user.avatar? %>
          <%= f.text_field :remote_avatar_url %>
        </p>
     <% end %>
    

    【讨论】:

      猜你喜欢
      • 2011-05-20
      • 2017-12-06
      • 2014-08-31
      • 1970-01-01
      • 2016-04-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多