mongoid

    0熱度

    1回答

    我試圖爲數組中的每個名稱創建單獨的記錄。這個數組通過一個控制器中的表單產生,並且單獨的記錄需要保存在一個連接(類型)表中(我知道mongo中沒有「連接」表,但它是描述它的最好方式)。目前使用Mongoid/MongoDB運行Rails 5。 始發形式: <%= form_tag create_multiple_batch_keg_index_path, method: :create

    0熱度

    1回答

    如何通過_id在mongoid中找到嵌入的文檔? 我已經Childrens嵌入式Parent,我想找到一個通過ID: Parent.where('children._id' => BSON::ObjectId(children_id).first 但此函數返回一個包含Parent給定ID的Children,而不是Children本身。 感謝

    0熱度

    1回答

    在我的項目中,我沒有使用表單發送圖像。我正在從路上走。 如何才能使用唯一路徑保存圖像? 我有這個模型 class Picture include Mongoid::Document include Mongoid::Paperclip has_mongoid_attached_file :avatar end 我(與MySQL這部作品在回形針)tryied這個

    2熱度

    3回答

    屬性我有一個User模型中嵌入一個Profile: # app/models/user.rb class User embeds_one :profile end # app/models/profile.rb class Profile embedded_in :user, inverse_of: :profile field :age, type: in

    0熱度

    1回答

    試圖用另一個帳戶登錄,我發現在登錄時不會再詢問一個gmail帳戶。 我的動作/方法是這樣的 class Users::SessionsController < Devise::SessionsController def destroy super cookies.delete :_myapp_session end end 它來這裏刪除方法在rou

    0熱度

    1回答

    我有一個架構基於過濾器在父模型新mongoid標準,其中產品的has_many文章 我取回我的文章模型創建基於示波器一個mongoid標準: criteria = Article.published.with_image 從這個標準,我現在想要查找其產品具有特定subject_id(或subject_id的子集)的所有文章。 我試圖被軟件寫: criteria = criteria.in('p

    0熱度

    1回答

    誰知道是什麼where(:genres.in => [ "rock" ]意味着mongoid 我看到文件這些代碼:?? class Band include Mongoid::Document field :country, type: String field :genres, type: Array scope :english, ->{ where(

    1熱度

    2回答

    有沒有辦法只爲只讀文檔設置created_at時間戳? 目前,我有以下消息類 class Message include Mongoid::Document include Mongoid::Timestamps field :text, type: String belongs_to :user, foreign_key: :user_id

    2熱度

    1回答

    我有一個Rails 4.2.8應用程序使用Mongoid 5.2.0。我想在沒有更新數據庫的情況下更新記錄。基本上,我想模仿User.new(user_params),而是更新。 現在,ActiveRecord有assign_attributes方法,但Mongoid版本似乎無論如何更新數據庫!這是一個錯誤還是有另一種方法來達到這個目的?

    0熱度

    1回答

    我有兩個模型'Product'和'Variant',產品有很多變體,現在我必須設置一個名爲「Ingridient」的變體的新模型的關聯,Variant有很多種ingridients.but在ingridents我想表明它再次HAS_ONE產品和variant.for例如 class Variant has_many :ingridients belongs_to :produc