This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UsersController < ApplicationController | |
def new | |
@user = User.new | |
end | |
def create | |
@user = User.new(users_params) | |
if @user.save | |
flash[:notice] = "You have successfully registered, please log in!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreateUsers < ActiveRecord::Migration | |
def change | |
create_table :users do |t| | |
t.string :username | |
t.timestamps | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User < ActiveRecord::Base | |
has_many :posts | |
end | |
class Post < ActiveRecord::Base | |
belongs_to :user | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get '/' do | |
if session[:player_name] | |
redirect '/welcome' | |
else | |
redirect '/game' | |
end | |
end | |
get '/welcome' do | |
erb :welcome |
NewerOlder