Skip to content

Instantly share code, notes, and snippets.

@JFickel
JFickel / gist:3936765
Created October 23, 2012 04:52
source
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta content="authenticity_token" name="csrf-param" />
<meta content="fPle5r0Yt+C+ZWSf6ap4ctD+2CBuMxNrSBFaBViEM6M=" name="csrf-token" />
<script src="/assets/jquery.js?body=1" type="text/javascript"></script>
<script src="/assets/jquery_ujs.js?body=1" type="text/javascript"></script>
<script src="/assets/jquery-ui.js?body=1" type="text/javascript"></script>
@JFickel
JFickel / gist:3936730
Created October 23, 2012 04:41
javascript not running
show.html.erb
<% content_for :javascript_includes do %>
<%= javascript_include_tag "colleges.js" %>
<% end %>
application.html.haml
!!!
%html
>>>>> index.html.haml
%h1 Chat
%ul#chat
= render @chat_messages
= form_for ChatMessage.new, remote: true do |f|
= f.text_field :content
= f.submit "Send"
@JFickel
JFickel / gist:3852166
Created October 8, 2012 12:04
broken accordion
%aside
%nav#sidenav
#team-sidenav
#accordion2.accordion
- if @current_user.teams.present?
- @current_user.teams.each_with_index do |team, i|
- i += 1
.accordion-group
.accordion-heading
%a.accordion-toggle{"data-parent" => "#accordion2", "data-toggle" => "collapse", :href => "#collapse#{i.to_words.capitalize}"}
@JFickel
JFickel / gist:3792252
Created September 27, 2012 05:03
received_notes not working
class User < ActiveRecord::Base
has_many :notes, foreign_key: "sender_id", dependent: :destroy
has_many :outgoing_notes, through: :notes, source: :user_recipient
has_many :incoming_notes, as: :receivable ,
class_name: "Note",
dependent: :destroy
has_many :received_notes, through: :incoming_notes, source: :sender
end
@JFickel
JFickel / gist:3792082
Created September 27, 2012 04:02
edit
class Note < ActiveRecord::Base
attr_accessible :description, :sender_id, :receivable_id
belongs_to :sender, class_name: "User"
belongs_to :receivable
end
class User < ActiveRecord::Base
has_many :notes, foreign_key: "sender_id", dependent: :destroy
has_many :outgoing_notes, through: :notes, source: :user_recipient
@JFickel
JFickel / gist:3792036
Created September 27, 2012 03:38
Note Domain Modeling
class Note < ActiveRecord::Base
attr_accessible :description, :sender_id, :user_recipient_id, :team_recipient_id, :tournament_recipient_id
belongs_to :sender, class_name: "User"
belongs_to :user_recipient, class_name: "User"
belongs_to :team_recipient, class_name: "Team"
belongs_to :tournament_recipient, class_name: "Tournament"
end
class User < ActiveRecord::Base
@JFickel
JFickel / gist:3594329
Created September 2, 2012 02:54
full trace
app/controllers/users_controller.rb:108:in `show'
actionpack (3.2.6) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.2.6) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.2.6) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (3.2.6) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.2.6) lib/active_support/callbacks.rb:425:in `_run__1894844828375605454__process_action__2695461369699905874__callbacks'
activesupport (3.2.6) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.6) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
activesupport (3.2.6) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.6) lib/abstract_controller/callbacks.rb:17:in `process_action'
@JFickel
JFickel / gist:3593075
Created September 2, 2012 01:09
server log
Started DELETE "/teams/1" for 127.0.0.1 at 2012-09-01 20:04:10 -0500
Processing by TeamsController#destroy as HTML
Parameters: {"id"=>"1"}
WARNING: Can't verify CSRF token authenticity
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" IS NULL LIMIT 1
Team Load (0.1ms) SELECT "teams".* FROM "teams" WHERE "teams"."id" = ? LIMIT 1 [["id", "1"]]
Completed 500 Internal Server Error in 2ms
@JFickel
JFickel / gist:3593067
Created September 2, 2012 01:09
Teams controller
class TeamsController < ApplicationController
before_filter :only => [:edit, :update, :destroy] do |action|
action.redirect_if_not_team_admin(Team.find(params[:id]), @current_user)
end
def index
@teams = Team.all
respond_to do |format|