This file contains 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
// pasting relevant bits | |
$scope.createPost = function() { | |
$http({ | |
method: 'POST', | |
url: '/db/createpost', | |
data: $scope.postFormModel, | |
headers: {'Content-Type': undefined}, | |
}).then(function successCallback(data) { | |
console.log(data); |
This file contains 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
result = Rails.cache.fetch('google_analytics_api/#{cache_key}', expires_in: 2.hours) { client.execute(:api_method => analytics.data.ga.get, :parameters => parameters) } |
This file contains 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 Pageviews < ActiveRecord::Base | |
#google analytics api shenanigans | |
require 'google/api_client' | |
require 'date' | |
include ReportingHelper | |
def self.getviews post | |
client, analytics, parameters = ReportingHelper.initclient | |
parameters = { |
This file contains 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
def update | |
respond_to do |format| | |
case params[:commit] | |
when "Save Draft" | |
@post.update_attribute(:is_draft, "yes") | |
format.html { redirect_to @post, notice: 'Post was successfully updated.' } | |
format.json { head :no_content } | |
when "Update Post" | |
@post.update_attribute(:is_draft, "no") | |
format.html { redirect_to @post, notice: 'Post was successfully updated.' } |
This file contains 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
$(document).ready(function(){ | |
setProjectHeroImage(); | |
setDominantColor('#color-target'); | |
}); | |
$(document).on('page:load', setProjectHeroImage); | |
$(document).on('page:load', setDominantColor); |
This file contains 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
h =[] | |
@posts.each do |p| | |
p.categories.each do |cat| | |
h << {p.id => cat.title} | |
end | |
end |
This file contains 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
@log.last.categories | |
=> #<ActiveRecord::Associations::CollectionProxy [#<Category id: 1, title: "General", description: "Toto", created_at: "2014-07-25 19:09:17", updated_at: "2014-07-30 14:50:42">, #<Category id: 6, title: "Highlight", description: "Some shenanigans on the way to the graveyard.", created_at: "2014-08-12 15:56:42", updated_at: "2014-08-12 15:56:42">]> |
This file contains 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
@post = Post.hero.group_by_category("include_with_hero", ["General"]) | |
#Intended result is all posts that fall under the category General AND Hero | |
#I want this to work with multiple categories, so something like | |
@post = Post.hero.group_by_category("include_with_hero", ["General", "Foo", "Bar"]) | |
#should return all posts that fall under General AND Foo AND Bar AND Hero categories |
This file contains 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 Attachment < ActiveRecord::Base | |
include Rails.application.routes.url_helpers | |
belongs_to :imageable | |
has_attached_file :picture, | |
:styles =>{ :medium => "660x", | |
:thumb => "150x" | |
}, | |
:url => "/attachments/pictures/:style/:basename.:extension", | |
:path =>"#{Rails.root}/public/attachments/pictures/:style/:basename.:extension" |
This file contains 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
<%= form_for(@post, html: {class:"dropzone"}) do |f| %> | |
<% if @post.errors.any? %> | |
<div class="error_explanation"> | |
<h2><%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:</h2> | |
<ul> | |
<% @post.errors.full_messages.each do |msg| %> | |
<li><%= msg %></li> | |
<% end %> | |
</ul> |
NewerOlder