Skip to content

Instantly share code, notes, and snippets.

View bazzel's full-sized avatar

Patrick Baselier bazzel

  • Oisterwijk, The Netherlands
View GitHub Profile
import DS from 'ember-data';
export default DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin, {
attrs: {
category: {embedded: 'always'}
}
});
export default function() {
this.get('/products', function(db, request) {
return {
data: db.products.map(attrs => (
{type: 'products', id: attrs.id, attributes: attrs }
))
};
});
}
@bazzel
bazzel / related1.rb
Last active September 8, 2015 19:25
Related posts, before and after
def similar_posts(post)
related_posts(post).tap do |posts|
(posts << @posts.first(2)).flatten!
end.first(2)
end
def related_posts(post)
categories_ids = post.categories.map(&:id)
@posts.select do |p|
<form role='form' class='well'>
<div class='form-group'>
{{input value=model.title class='form-control' placeholder='Enter a title'}}
</div>
<div class='form-group'>
{{textarea value=model.description class='form-control' placeholder='Enter a description'}}
</div>
<div class='form-group'>
{{input value=model.price class='form-control' type='number' step='0.01' placeholder='Enter a price'}}
</div>
<div class='form-group'>
{{#if model.image}}
<img src={{model.image}}>
<button type='button' class='remove pull-right'>Remove</button>
{{else}}
<img src='http://placehold.it/320x150&text=No image'>
{{/if}}
<div class='file'>
Browse...<input type='file' accept='image/*'>
</div>
{{#each starred}}
<span class="glyphicon glyphicon-star"></span>
{{/each}}
{{#each unstarred}}
<span class="glyphicon glyphicon-star-empty"></span>
{{/each}}
@bazzel
bazzel / html-ipsum.html
Last active November 23, 2015 07:32
myHTML-Ipsum
<!-- Sample Content to Plugin to Template -->
<h1 id='wrapper'>CSS Basic Elements</h1>
<p>The purpose of this HTML is to help determine what default settings are with CSS and to make sure that all possible HTML Elements are included in this HTML so as to not miss any possible Elements when designing a site.</p>
<hr />
<h1 id="headings">Headings</h1>
<h1>Heading 1</h1>
@bazzel
bazzel / README.md
Last active March 20, 2022 22:00
Webpacker and I18n
$ rails new my-i8n --webpack

Gemfile

gem 'i18n-js'
@bazzel
bazzel / README.md
Last active December 27, 2018 13:21
Ruby on Rails - Material Design
@bazzel
bazzel / README.md
Last active May 26, 2021 04:20
Rails 6 and Bootstrap 4

This blogpost shows how to setup Rails 6 with Bootstrap 4.

This snippet shows a somehow different and less customized approach.

$ rails new rails6-bootstrap4
$ bundle --binstubs
$ yarn add bootstrap jquery popper.js expose-loader