Skip to content

Instantly share code, notes, and snippets.

View marcoroman89's full-sized avatar

Marco Roman marcoroman89

View GitHub Profile
@marcoroman89
marcoroman89 / gist:6035058
Created July 19, 2013 04:01
Procedural Ruby Blackjack app
puts "****************************"
puts "Welcome to Ruby Blackjack!"
puts "****************************"
puts ""
# Deck and Suit
suits = ['Diamonds', 'Spades', 'Hearts', 'Clubs']
cards = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'King', 'Queen', 'Ace']
@marcoroman89
marcoroman89 / gist:6035080
Last active December 19, 2015 23:29
Object Orientated Ruby Blackjack app
class Card
attr_accessor :suit, :face_value
def initialize(s, fv)
@suit = s
@face_value = fv
end
def pretty_output
"The #{face_value} of #{find_suit}"
get '/' do
if session[:player_name]
redirect '/welcome'
else
redirect '/game'
end
end
get '/welcome' do
erb :welcome
@marcoroman89
marcoroman89 / gist:6099031
Created July 28, 2013 15:48
Rails ActiveModel Error
ActiveModel::MassAssignmentSecurity::Error in Devise::RegistrationsController#create
Can't mass-assign protected attributes: email, password, password_confirmation
Rails.root: /Users/marcoroman/projects/treebook
Application Trace | Framework Trace | Full Trace
Request
Parameters:
@marcoroman89
marcoroman89 / gist:6100302
Created July 28, 2013 21:23
The start of my procedural blackjack game!
# Interactive Ruby Based Blackjack Game
def calculate_total(cards) #[['H', '3'] ['K', '7']]
end
puts "Welcome to Ruby Blackjack"
suits = ['H', 'D', 'S', 'C']
cards = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A']
@marcoroman89
marcoroman89 / gist:6113711
Created July 30, 2013 14:59
Getters and Setters
class Card
attr_accessor :suit, :face_value
def initialize(s, fv)
@suit = s
@face_value = fv
end
def suit_output
puts "The #{face_value} of #{find_suit}"
@marcoroman89
marcoroman89 / gist:6113713
Created July 30, 2013 15:00
Getters and Setters
class Card
attr_accessor :suit, :face_value
def initialize(s, fv)
@suit = s
@face_value = fv
end
def suit_output
puts "The #{face_value} of #{find_suit}"
@marcoroman89
marcoroman89 / gist:6143465
Created August 2, 2013 21:07
Cannot run rails server after ruby 2.0 and rails 4.0 installation
Marcos-MacBook-Pro:~ marcoroman$ rails -v
Rails 4.0.0
Marcos-MacBook-Pro:~ marcoroman$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.4.0]
Marcos-MacBook-Pro:~ marcoroman$ cd blog
Marcos-MacBook-Pro:blog marcoroman$ ls
Gemfile Rakefile bin config.ru lib public tmp
README.rdoc app config db log test vendor
Marcos-MacBook-Pro:blog marcoroman$ rails server
/usr/local/rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:51:in `require': cannot load such file -- bundler/setup (LoadError)
class User < ActiveRecord::Base
has_many :posts
end
class Post < ActiveRecord::Base
belongs_to :user
end
class CreatePosts < ActiveRecord::Migration
def change
create_table :post do |t|
t.string :title, :url
t.text :description
t.integer :user_id
t.timestamps
end
end
end