Skip to content

Instantly share code, notes, and snippets.

View dchapman1988's full-sized avatar

David Chapman dchapman1988

View GitHub Profile
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'file_decrypter'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
def show
if current_user
unless current_user.stocks?
redirect_to root_path, :notice => "You need to add some stocks first."
end
@stocks = current_user.stocks
else
redirect_to new_user_session_path
end
end
@dchapman1988
dchapman1988 / Admin Index View
Created June 23, 2011 15:36
Problem updating all stocks...
# As the method, I have tried :put and :update.
= button_to 'Update all quotes', admin_panel_path, :method => :put
%h2 Admin Control Panel
%br/
%div{ :style => "float:left;" }
%h3 Add stocks
%br/
= form_tag(new_admin_stock_path, :method => :get) do
= label_tag(:symbol, "Symbols")
%br/
= text_area_tag(:symbol, nil, :cols => 30, :rows => 10)
%br/
def index
if current_user.admin
@stocks = Stock.all
else
redirect_to root_path
flash[:error] = "You must be an administrator to access this page!"
end
end
$ bundle exec rake db:create
(in /home/david/work/xrono)
rake aborted!
Lemonade is deprecated now. You may want to use Compass Sprites from now on. More information:
https://github.com/hagenburger/lemonade
/home/david/.rvm/gems/ruby-1.9.2-p180/gems/lemonade-0.3.5/lib/README.md
/home/david/work/xrono/Rakefile:4:in `require'
(See full trace by running task with --trace)
module Sorcery
module Model
module Submodules
# The API Token submodule automatically generates a token that can
# be used to login to the website on every visit.
module APIToken
def self.included(base)
base.sorcery_config.class_eval do
attr_accessor :api_token_attribute_name, # the attribute in the model class.
:api_token_expires_at_attribute_name, # the expires attribute in the model class.
@dchapman1988
dchapman1988 / ability.rb
Created July 12, 2011 18:02
Lines 9-11 make me happy :-)
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new # guest user (not logged in)
if user.admin?
can :manage, :all
elsif user.manager?
can :manage, Client, Client.where(:user_id => user.id) do |client|
client.user_id == user.id
$ rake cucumber
/home/david/.rvm/rubies/ruby-1.9.2-p180/bin/ruby -S bundle exec cucumber --profile default
Using the default profile...
Feature: API Authorization
Background: # features/api/authorization.feature:3
Given a role exists with name: "manager" # features/step_definitions/role_steps.rb:1
And there is a user with username "manager-user" and API token "b390294aad6811e0a7cc0030679f1d6a" # features/step_definitions/user_steps.rb:1
And the user with username "manager-user" has role a manager role # features/step_definitions/user_steps.rb:5
And the user with username "manager-user" has a client named "Manager Client 1" # features/step_definitions/client_steps.rb:1
Installing rmagick (2.13.1) with native extensions /home/david/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:533:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)
/home/david/.rvm/rubies/ruby-1.9.2-p180/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for gcc... yes
checking for Magick-config... no
Can't install RMagick 2.13.1. Can't find Magick-config in /home/david/.rvm/gems/ruby-1.9.2-p180/bin:/home/david/.rvm/gems/ruby-1.9.2-p180@global/bin:/home/david/.rvm/rubies/ruby-1.9.2-p180/bin:/home/david/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/lib/jvm/java-6-sun-1.6.0.24/jre/bin:/usr/lib/jvm/java-6-sun-1.6.0.24/jre/bin
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of