我正在使用carrierwave并且有一个错误未知运算符:$ oid(2)

时间:2017-05-29 06:21:43

标签: ruby-on-rails mongodb carrierwave

我正在尝试上传文件并显示文件数据,如帖子。我正在使用carrierwave上传文件。这里是详细信息 的 index.html.erb

{
  "name": "Screen Recorder",
  "description": "Record a video of your computer screen",
  "version": "0.4",
  "manifest_version": 2,
  "icons": {
     "16": "icon.png",
     "128": "icon.png"
  },
  "background": {
       "scripts": [ 
          "background.js",
          "ourrecorder.js"
       ]
  },
  "browser_action": {
       "default_icon": "icon.png", 
       "default_popup": "receiver.html"
  },

  "permissions": [
    "desktopCapture",
    "tabCapture",
    "notifications",
    "unlimitedStorage"
   ]
}

Postscontroller.rb

    <div style="margin-bottom:0px;margin-left:430px;margin-top:50px;width:30%;">
                <%= form_for Post.new, :url => {:action => 'create'}, :html => {:multipart => true} do |f| %>
                    <%= f.file_field :attachment , class: "filestyle"%>
                    <%= f.hidden_field :user_id, :value => current_user.id %>
                    <%= f.submit "Upload" , class: "btn btn-primary btn-block" ,style:"margin-top:8px;" %>
                <% end %>
            </div>

的routes.rb

    def index
          @posts = Post.all
          @user = User.find_by(id: params[:user_id])
       end

       def create
          @post = Post.new(post_params)
          @user = User.find_by(id: params[:user_id])

          if @post.save
             redirect_to :action => 'index'
             flash[:notice] = "The post has been uploaded."
          else
             render "index"
          end
       end
     private
          def post_params
          params.require(:post).permit(:attachment,:user_id)
       end

当我尝试上传文件时,它显示错误 未知运营商:$ oid(2)。我不知道为什么会发生这种情况。我是新手,请帮助我克服这个错误。

0 个答案:

没有答案