Socket
Book a DemoInstallSign in
Socket

monglobal

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

monglobal

0.0.5
bundlerRubygems
Version published
Maintainers
1
Created
Source

This is a Rails plugin for MongoMapper that allows you to translate your models in a way that is similar to the Globalize gem for ActiveRecord.

After heading down this path for several days I found https://github.com/ahe/mongo_translation and decided I like their implimentation of the klass better but it needed a few changes to make it easier to use from a rails controller.

USAGE: First add to your Gemfile gem 'monglobal'

Then run bundle install

Then in your model:

class Post

include MongoMapper::Document
include Monglobal

translates :title, :body

key :title,       String
key :body,        String

end

Now your controller is pretty much the same with one difference to how you update a record. Instead of using update_attributes use this on your update method.

def create post = Post.new(params[:post]) if post.save redirect_to translate_posts_path(params[:locale]) end end

def update post = Post.find(params[:id]) post.update_translation(params[:locale], params[:post]) redirect_to translate_posts_path(params[:locale]) end

The sample app here might help with some of the details of switching the locale and setting up the default locale.

FAQs

Package last updated on 15 Jan 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.