Skip to content

Instantly share code, notes, and snippets.

View alexrothenberg's full-sized avatar

Alex Rothenberg alexrothenberg

View GitHub Profile
class Person #existing implementation
def find_by_name name
filter = adapter.create_equality_filter('uid', "*#{name}*")
results = find(:base => '', :attributes => attribute_mapping.values, :filter => filter)
build_array_of_people_from results
end
def find_by_exact_name name
filter = adapter.create_equality_filter('uid', "#{name}")
results = find(:base => '', :attributes => attribute_mapping.values, :filter => filter)
if (results.size > 1)
def to_factory model
model.columns.each do |c|
if c.null == false
value = case c.type
when :integer
"7"
when :string
"'hi'"
when :boolean
'false'
# Install admin_data
plugin 'admin_data', :git => 'git://github.com/alexrothenberg/admin_data.git'
# In DOS type
### cd \workshop
### mkdir ruby_exercises
### cd ruby_exercises
# Open the e editor
### e .
# Create a new file called array_exercise.rb
# In DOS type
### cd \workshop
### mkdir ruby_exercises
### cd ruby_exercises
# Open the e editor
### e .
# Create a new file called hash_exercise.rb
# In DOS type
### cd \workshop
### mkdir ruby_exercises
### cd ruby_exercises
# Open the e editor
### e .
# Create a new file called string_exercise.rb
# In DOS type
### cd \workshop
### mkdir ruby_exercises
### cd ruby_exercises
# Open the e editor
### e .
# Create a new file called symbol_exercise.rb
# test/unit/team_test.rb
require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'test_helper')
class TeamTest < ActiveSupport::TestCase
test 'can save a team in the database' do
team = Team.new(:name => 'Liverpool')
team.save!
team_from_database = Team.find(team.id)
<h3>Create a New Team</h3>
<% form_for @team do |form| %>
<%= form.label :name %>
<%= form.text_field :name %>
<%= submit_tag %>
<% end %>
def create
@team = Team.create!(params[:team])
redirect_to team_url(@team)
end