Skip to content

Instantly share code, notes, and snippets.

@Siron
Siron / gist:a36d0d17065b91eb4f91
Created November 9, 2015 17:03
Generic DB functions
var Repository = function(model) {
};
Repository.prototype.get = function(id) {
};
Repository.prototype.find = function(query) {
};
Repository.prototype.list = function(query, options) {
{
"name": "some-app",
"version": "0.3.0",
"private": true,
"scripts": {
"start": "node app.js"
},
"dependencies": {
"body-parser": "~1.4.3",
"bower": "^1.3.12",
$scope.loadEditor = ->
$scope.data = Stories.get
id: $routeParams.id
, (article) ->
$scope.data.errors = {}
editorData = []
editorData = article.content if article.content
editorData = []
$scope.editor.onFormSubmit()
data = $scope.editor.store.retrieve()
data.data.forEach (block) ->
unless _.isEmpty(block.data)
editorData.push
position: block.position
type: block.type
$scope.buildForSave = ->
editorData = []
$scope.editor.blocks.forEach (block) ->
$scope.editor.saveBlockStateToStore block
unless _.isEmpty(block.blockStorage.data)
editorData.push
position: block.$el.index()
type: block.blockStorage.type
utf8:✓
_method:put
authenticity_token:VSN+cPF54imIoyesRgCUSPF/0jRvdwCh+Qxd4SDsxmo=
switch_locale:en
page[title]:About
page[parts_attributes][0][body]:<p>This is just a standard text page example. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin metus dolor, hendrerit sit amet, aliquet nec, posuere sed, purus. Nullam et velit iaculis odio sagittis placerat. Duis metus tellus, pellentesque ut, luctus id, egestas a, lorem. Praesent vitae mauris. Aliquam sed nulla. Sed id nunc vitae leo suscipit viverra. Proin at leo ut lacus consequat rhoncus. In hac habitasse platea dictumst. Nunc quis tortor sed libero hendrerit dapibus.
Integer interdum purus id erat. Duis nec velit vitae dolor mattis euismod. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Suspendisse pellentesque dignissim lacus. Nulla semper euismod arcu. Suspendisse egestas, erat a consectetur dapibus, felis orci cursus eros, et sollicitudin purus urna et metus. Integer eget est sed nunc euismod v
activerecord (3.2.1) lib/active_record/relation/delegation.rb:45:in `method_missing'
activerecord (3.2.1) lib/active_record/associations/collection_proxy.rb:101:in `method_missing'
vendor/engines/refinerycms-photo-gallery/lib/refinery/photo_gallery/extensions/pages_extension.rb:31:in `album_page='
activerecord (3.2.1) lib/active_record/attribute_assignment.rb:94:in `block in assign_attributes'
activerecord (3.2.1) lib/active_record/attribute_assignment.rb:93:in `each'
activerecord (3.2.1) lib/active_record/attribute_assignment.rb:93:in `assign_attributes'
(eval):3:in `block in assign_attributes'
globalize3 (0.2.0) lib/globalize/active_record/instance_methods.rb:170:in `with_given_locale'
(eval):3:in `assign_attributes'
activerecord (3.2.1) lib/active_record/persistence.rb:212:in `block in update_attributes'
<%= f.fields_for @page.album_page do |album_page_form| %>
<%= album_page_form.label :album_id, t('.join_page_with_album') %>
<%= album_page_form.grouped_collection_select( :album_id, Refinery::PhotoGallery::Collection.includes(:albums).all, :albums, :title, :id, :title,
{ :include_blank => true},
{ :data => {
:placeholder=> t('.choose_album')},
:multiple=> false,
:class=> "chzn-select-deselect",
:style=>"min-width: 300px;"
module Refinery
module PhotoGallery
module Extensions
module Pages
def has_one_page_album
has_many :album_page, :as => :page, :dependent=> :destroy
has_many :album, :through => :album_page
has_many :photos, :class_name => Refinery::PhotoGallery::Photo, :through => :album , :order=> "created_at ASC"
@Siron
Siron / gist:5282252
Last active December 15, 2015 15:29
vendor/engines/refinerycms-photo-gallery/lib/refinery/photo_gallery/extensions/pages_extension.rb:43:in `[]'
vendor/engines/refinerycms-photo-gallery/lib/refinery/photo_gallery/extensions/pages_extension.rb:43:in `block in album_page='
vendor/engines/refinerycms-photo-gallery/lib/refinery/photo_gallery/extensions/pages_extension.rb:38:in `each'
vendor/engines/refinerycms-photo-gallery/lib/refinery/photo_gallery/extensions/pages_extension.rb:38:in `album_page='
activerecord (3.2.1) lib/active_record/attribute_assignment.rb:94:in `block in assign_attributes'
activerecord (3.2.1) lib/active_record/attribute_assignment.rb:93:in `each'
activerecord (3.2.1) lib/active_record/attribute_assignment.rb:93:in `assign_attributes'
(eval):3:in `block in assign_attributes'
globalize3 (0.2.0) lib/globalize/active_record/instance_methods.rb:170:in `with_given_locale'
(eval):3:in `assign_attributes'