Displaying a Carrierwave filename in the view

前端 未结 10 1141
暖寄归人
暖寄归人 2020-12-13 23:29

I am trying to display the filename of a Carrierwave attachment in a Rails erb template. The following does not work:

<%= @page.form.filename %>
         


        
10条回答
  •  长情又很酷
    2020-12-13 23:58

    If you're using ActiveRecord, you can directly access the field named form in two ways:

    def my_method
      self[:form]
    end
    

    or

    def my_method
      form_before_type_cast
    end
    

    The second method is read-only.

提交回复
热议问题