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
| class Post | |
| 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
| class Tag | |
| def posts | |
| post_scope = ->(tag) { where '? = ANY (posts.tags)', tag.id } | |
| options = {} | |
| reflection = ActiveRecord::Reflection::HasManyReflection.new(:posts, post_scope, options, self.class) | |
| association = PostsAssociation.new(self, reflection) | |
| @posts ||= ActiveRecord::Associations::CollectionProxy.new(Post, association) | |
| end | |
| private |
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
| var div = document.createElement('div') | |
| div.innerHTML = "<script></script>" | |
| var s = div.children[0] | |
| s.src = "//connect.facebook.net/en_US/all.js#xfbml=1" | |
| // true | |
| s instanceof HTMLScriptElement | |
| // Will NOT load the script | |
| document.head.appendChild(s) |
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
| link_to meal_ingredients_path(meal) do |link| | |
| if meal.ingredients.need > 0 | |
| "Liste d'épicerie — il vous manque #{meal.ingredients.need} ingrédients" | |
| else | |
| link[:class] << 'complete' | |
| "Vous avez tous les ingrédients!" | |
| end | |
| 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
| where("logs.products ?| ARRAY[:ids]", ids: products.map(&:id).uniq.map(&:to_s)) |
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
| <!-- This work for a new contact, but will not for an existing contact --> | |
| <%= form_for [contact.client, contact] do |f| %> | |
| <% end %> | |
| <!-- This work for an existing contact, but will not for a new contact --> | |
| <%= form_for [contact] do |f| %> | |
| <% 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
| class FollowersController < ApplicationController | |
| before_action :authenticate! | |
| def index | |
| @pictures = current_user.followers.pictures | |
| end | |
| 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
| class Popup | |
| loaded: => | |
| @on 'dates:index', @show | |
| show: (e) => | |
| @scrollTop = document.body.scrollTop | |
| document.body.appendChild(e.HTML) | |
| main = document.body.querySelector('main') | |
| main.classList.add('overlayed') | |
| main.style.top = "-#{@scrollTop}px" |
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
| e.HTML = "<%= j content_tag(:div, render('list', posts: @posts), class: %w(popup)) %>".toHTML() |
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
| module ContentTagHelper | |
| def content_tag(*args) | |
| if block_given? | |
| tag = Tag.new(args[0], args[1] || {}) | |
| old_buf = @output_buffer | |
| @output_buffer = ActionView::OutputBuffer.new | |
| value = yield(tag) | |
| content = tag.render(@output_buffer.presence || value) | |
| @output_buffer = old_buf | |
| content |