This file contains hidden or 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
<%= form_for [@website, @billboard], :html => { :multipart => true } do |f| %> | |
<div class="row_margin_bottom"> | |
<%= f.label :name %> | |
<%= f.text_field :name %> | |
</div> | |
<div class="form_row"> | |
<%= label_tag :photos %> | |
<div class="billboard-container"> |
This file contains hidden or 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
field_type = params[:form_field][:field_type] | |
case field_type | |
when 'text' | |
@form_field.code = %Q{<input type="text" name="#{@form_field.id}-text-field" class="text-input">} | |
when 'radio' | |
@field_option.code = %Q{<input type="radio" name="form_field_#{@form_field.id}-radio_field_#{@field_option.id}" class="radio-option-label">} | |
@field_option.save | |
when 'checkbox' | |
@field_option.code = %Q{<input type="checkbox" name="form_field_#{@form_field.id}-checkbox_field_#{@field_option.id}" class="checkbox-option-label">} | |
@field_option.save |
This file contains hidden or 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
require 'spec_helper' | |
describe 'Member Signup Page' do | |
it 'loads the signup form' do | |
visit '/members/new' | |
page.should have_content('Signup') | |
end | |
it "creates a new member in the database" do |
This file contains hidden or 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
#start a new game by calling Game.new with player names as params, i.e. g = Game.new("Nick", "Mike") | |
#the Game object will contain the deck & the players. | |
#A new Deck will be automatically reloaded as soon as all cards are gone. | |
#As a result, you can play endless hands of blackjack. | |
SUITS = %w{clubs hearts spades diamonds} | |
VALUES = ["2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"] | |
AMOUNTS = [2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11] |
This file contains hidden or 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
SUITS = %w{clubs hearts spades diamonds} | |
VALUES = ["2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"] | |
AMOUNTS = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] | |
Card = Struct.new(:value, :suit, :amount) | |
class Deck < Array | |
def initialize |
This file contains hidden or 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
SUITS = %w{clubs hearts spades diamonds} | |
VALUES = [2, 3, 4, 5, 6, 7, 8, 9, 10, "J", "Q", "K", "A"] | |
Card = Struct.new(:value, :suit, :amount) | |
$deck = [] | |
SUITS.each do |suit| | |
VALUES.each do |value| |
This file contains hidden or 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
source 'http://rubygems.org' | |
gem 'sinatra' | |
gem 'activerecord' | |
gem 'sinatra-activerecord' # excellent gem that ports ActiveRecord for Sinatra | |
gem 'thin' | |
group :development, :test do | |
gem 'sqlite3' | |
end |
This file contains hidden or 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
hello from the view | |
<form action="/form" method="post"> | |
<input type="text" name="name"> | |
<input type="submit"> | |
</form> |
This file contains hidden or 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 Ability | |
include CanCan::Ability | |
def initialize(user) | |
user ||= User.new #guest user | |
can :manage, :all if user.role == "owner" | |
if user.role == "employee" | |
can :read, Company |
This file contains hidden or 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
I changed my table "companies", to "projects" and went through and updated all the references to company/companies. Everything is working fine, except I am again getting that same validation error when I try to create a new task on the projects/4/tasks/new. It's not getting the project_id and therefore the validation is failing. If I hard code the params[:project_id] with the actual number of the project, it creates fine. | |
I tried all the same things we did yesterday and the day before, to no avail. | |
**********Here's the error message: | |
ActiveRecord::RecordInvalid in TasksController#create | |
Validation failed: Project can't be blank |