Skip to content

Instantly share code, notes, and snippets.

View andruu's full-sized avatar
😎
What is this?

Andrew Weir andruu

😎
What is this?
View GitHub Profile
@andruu
andruu / gist:1455742
Created December 10, 2011 17:47
I have a post model which has_many comments and a comment model which belongs_to a user and I am looping through the comments trying to get the users information. if i do comment.user.to_yaml I can see all of the attributes but when I try to get the usern
show.html.slim
- @post.comments.each do |comment|
div.comment
# Works and shows user attributes
/ --- !ruby/object:User
/ aggregation_cache: {}
/
/ association_cache: {}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Action Controller: Exception caught</title>
<style>
body { background-color: #fff; color: #333; }
body, p, ol, ul, td {
if cookies[:post_view][@post.id].blank?
cookies[:post_view][@post.id] = true
@post.increment!(:view_count)
end
shopping_cart.values.reduce(:+) * 24.99
@andruu
andruu / index.html
Created December 3, 2012 23:38
Angular.js Tutorial
<!DOCTYPE HTML>
<html lang="en-US" ng-app="Site">
<head>
<meta charset="UTF-8">
<title>Angular.js Tutorial</title>
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/css/bootstrap.min.css" rel="stylesheet">
<style type="text/css">
body {
padding-top:60px;
}
@font-face {
font-family: 'FontAwesome';
src: url('../font/fontawesome-webfont.eot');
src: url('../font/fontawesome-webfont.eot?#iefix') format('embedded-opentype'), url('../font/fontawesome-webfont.woff') format('woff'), url('../font/fontawesome-webfont.ttf') format('truetype'), url('../font/fontawesome-webfont.svg#FontAwesome') format('svg');
font-weight: normal;
font-style: normal;
}
# Tabs
$('.tab').on 'click', ->
$('.tab').removeClass('active')
$(this).addClass('active')
opens = $(this).data('opens')
$('.tab-content').hide()
$(".tab-content[data-id='#{opens}']").show()
( ! ) A fatal error has occurred. Please see the Default.log file for 2013-01-08. Request ID: a8c8ed
Programmer Error: Uncaught exception of type "ErrorException"
Application: Client
InterfaceBundle: Default
Request URI: /files/font/fontawesome-webfont.svg
Redirect Query String: eg_requestClass=file&eg_requestID=rawfile&file_name=font/fontawesome-webfont.svg
Request URL: http://petflow3.site/files/font/fontawesome-webfont.svg
protected function resolveAction ($action, $method = 'GET') {
$this->action = $action;
parent::resolveAction($action, $method);
}
public function before () {
if ($this->action == 'your_action_here') {
// do stuff
} else {
// do other stuff
class User < ActiveRecord::Base
attr_accessible :email, :first_name, :last_name
has_one :shopping_cart
has_and_belongs_to_many :addresses
has_and_belongs_to_many :payment_options
validates :email, uniqueness: true, presence: true, format: { with: /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i }
has_secure_password
def self.authenticate(email, password)