Giter VIP home page Giter VIP logo

mongoid_globalize's Introduction

Hi there ๐Ÿ‘‹

trophy

mongoid_globalize's People

Contributors

dependabot[bot] avatar mikdiet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

mongoid_globalize's Issues

Translations from form

First of all, great gem!

How would I be able to translate 1 (or more) fields to 2 (or more) languages from a form? I couldn't find anything on nested_attributes.

Cant Modify Frozen Hash On Delete

I have the following model:

class Activity
include Mongoid::Document
include Mongoid::Slug
include Mongoid::Globalize

references_and_referenced_in_many :categories, :inverse_of => :activities, :dependent => :nullify, :validate => false

translates do
field :name
fallbacks_for_empty_translations!
end

slug :name, :permanent => true do |doc|
"#{doc.translated_attributes['name']}"
end

accepts_nested_attributes_for :categories, :category_ids
accepts_nested_attributes_for :translations, :allow_destroy => true, :reject_if => proc {|rec| rec['name'].blank?}

attr_accessible :name, :categories, :category_ids, :translations

validates :name, default_locale: true
validates :name, unique_in_locale: true

end

Using Mongoid 2.3.1 and Rails 3.1.1 in console I get the output shown by this gist:

https://gist.github.com/1280740

I upgraded your gem to use mongoid 2.3.1 and wrote a delete test all of these tests pass, I also tried without mongoid slug and I am still getting the same error. I am still trying to debug this but if you have any ideas as to what might be causing this it would be helpful. I note that this is crashing in the method you indicated as the most "trouble".

By the way not withstanding the error message the record is deleted from the database

.build and save results in nil attributes

I'm having some weird issues using nested attributes and building embedded models.

When using .build and specifying attributes, on save the embedded model creates an embedded translation doc, with the proper locale set. However, all of its attributes are blank.

For instance, I have a page model, and an embedded Content model. Content is subclassed (perhaps thats the culprit?) with a model called TextBlock which has a "body" attribute.

page.contents.build({ body: "some content" }, TextBlock)
# misc code here
page.save

Upon save inspecting the embedded TextBlock I have one embedded translation for :en (default locale) but its body, as well as the body on the model itself are both blank.

I'm wondering if its something to do with the changes mongoid made recently with how embedded docs persist mentioned here because if I re-save the embedded doc after the parent is saved, the attributes/translations are properly saved

class Page
  after_save :resave_contents

  def resave_contents
    self.contents.each(&:save)
  end
end

page.contents.first.inspect #=> <TextBlock _id: 4ee6e3644dd9624091000010, _type: "TextBlock", created_at: 2011-12-13 05:32:20 UTC, updated_at: 2011-12-13 05:32:20 UTC, position: 2, body: "some content">

All translations are also set properly.

In addition, as mentioned in the mongoid link above, when updating embedded docs with update_attributes, all attrs/translations are updated perfectly, but using model.attributes= and model.write_attribute(key, value) or model.write_attribute(key, value, :locale => I18n.locale) don't seem to persist either.

I tried overriding the nested_attributes callback (contents_attributes=) and the documents update with the exception of translated attributes. Going through the code also got me to try doc.globalize.write(locale, key, value) but the updated attrs still don't persist.

Without translation enabled everything saves properly, and I'm wondering if this isn't an issue created with how mongoid handles setting embedded docs on the parent as of version 2.2.0. When creating/updating non-embedded docs everything works as expected.

I'm happy to fork and test a few things out, I was just wondering if anyone had any thoughts :)

DEPRECATION WARNING: The InstanceMethods module inside ActiveSupport::Concern will be no longer included automatically.

I get the following message when run rspec:
DEPRECATION WARNING: The InstanceMethods module inside ActiveSupport::Concern will be no longer included automatically. Please define instance methods directly in Address instead. (called from include at /Users/ik/Development/projects/booking/webapp/app/models/address.rb:3)

and line 3 of address.rb is include Mongoid::Spacial::Document

The same issue was fixed in mongoid :
https://github.com/mongoid/mongoid/issues/1525

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.