-
-
Save tsabat/1842581 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'mongo_mapper' | |
class Content | |
include MongoMapper::Document | |
attr_accessible :version, :html, :css, :js, :html_preprocessor, :css_preprocessor, :js_preprocesor | |
#Foreign Keys | |
key :user_id, String | |
key :slug_id, String | |
key :version, Integer | |
key :html, String | |
key :css, String | |
key :js, String | |
key :html_preprocessor, String | |
key :css_preprocessor, String | |
key :js_preprocesor, String | |
timestamps! | |
#TODO: validations | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'mongo_mapper' | |
require_relative '../models/content' | |
class ContentService | |
def initialize(db = 'tinkerbox') | |
MongoMapper.database = db | |
end | |
def save_content(content) | |
begin | |
Content.new(content).save | |
rescue | |
#TODO: handle exceptions | |
throw "Fuck!" | |
end | |
end | |
end |
quezo
commented
Feb 16, 2012
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment