Skip to content

Instantly share code, notes, and snippets.

@JFickel
JFickel / gist:3593057
Created September 2, 2012 01:08
app controller
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :current_user
require 'open-uri'
require 'json'
require 'nokogiri'
require 'ostruct'
@JFickel
JFickel / gist:3523317
Created August 30, 2012 06:30
colleges.rake
require 'csv'
desc "Import colleges from csv file"
task :colleges => [:environment] do
file = "db/colleges.csv"
CSV.foreach(file, :headers => true) do |row|
Restaurant.create({
:name => row[1]
@JFickel
JFickel / gist:3520074
Created August 29, 2012 23:05
error message
OpenURI::HTTPError in UsersController#update
404 Not Found
Rails.root: /Users/jamesfickel/Desktop/g_testing/g_alpha
Application Trace | Framework Trace | Full Trace
app/controllers/users_controller.rb:43:in `block in update'
app/controllers/users_controller.rb:26:in `update'
Request
@JFickel
JFickel / gist:3520055
Created August 29, 2012 23:03
OpenURI::HTTPError in UsersController#update: app/controllers/users_controller.rb:43:in `block in update', app/controllers/users_controller.rb:26:in `update'
class UsersController < ApplicationController
def new
@user = User.new
end
def create
@user = User.new(params[:user])
if @user.save
flash[:notice] = "Thanks for signing up. Important! In order to have full functionality of the site, add your game accounts to your profile."
@JFickel
JFickel / gist:3520029
Created August 29, 2012 23:01
OpenURI::HTTPError in UsersController#update
def update
@user = User.find(params[:id])
respond_to do |format|
if @user.update_attributes(params[:user])
if @user.sc2_url?
if @user.sc2_url[7,2] == 'us'
@user.sc2_server = "US"
end
@JFickel
JFickel / gist:3363596
Created August 15, 2012 20:55
show view
<%= @sc2_character.achievement_points %>
<div id="profile_picture"><%= image_tag @user.image.url(:medium) %></div>
@JFickel
JFickel / gist:3363582
Created August 15, 2012 20:55
user controller
def show
if logged_in?
if !User.find(session[:user_id]).nil?
@user = User.find(session[:user_id])
else
redirect_to welcome_path
end
else
redirect_to welcome_path
end
@JFickel
JFickel / gist:3363570
Created August 15, 2012 20:54
Gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.6'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
gem 'paperclip'
gem 'aws-s3'
@JFickel
JFickel / gist:3363483
Created August 15, 2012 20:45
cannot load such file -- SC2Ranks
def show
require 'SC2Ranks'
if logged_in?
if !User.find(session[:user_id]).nil?
@user = User.find(session[:user_id])
else
redirect_to welcome_path
end
@JFickel
JFickel / gist:3037066
Created July 3, 2012 02:05
heroku wut
Warning: Permanently added the RSA host key for IP address '50.19.85.156' to the list of known hosts.
To [email protected]:mh-sample-app.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to '[email protected]:mh-sample-app.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again. See the
'Note about fast-forwards' section of 'git push --help' for details.