No commit activity in last 3 years
No release in over 3 years
longer description of your gem
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Project Readme

CCLS Engine¶ ↑

THIS APP AND REPO ARE NOW DEAD. AS OF TODAY, 20120313, THIS FUNCTIONALITY HAS OR WILL BE INCORPORATED INTO THE ODMS APPLICATION.

This is a gem, basic rails app and plugin/engine (GRAPE). As a gem, it shares functionality and access to the shared database. As an app, it is used to manage the migrations of the shared database. It is no longer really used as a plugin, but does contain the relevant features of an ‘engine’ including models, controllers, views and routes to the aforementioned resources.

Development Notes¶ ↑

As this code is stored in publicly accessible repositories, DO NOT UNDER ANY CIRCUMSTANCES PUT ANY REAL SUBJECT DATA IN THE CODE!

The models in this gem are stored in a shared database, therefore, the migrations that create and modify it, as well as the ActiveRecord models that use it must reflect this. Currently, the models which are normally subclasses of ActiveRecord::Base need to now by subclasses of ActiveRecordShared. The migrations, normally subclasses of ActiveRecord::Migration, need to be subclasses of SharedMigration.

Several errors I get on my MacBook when running rake test:coverage that I don’t get running autotest,

I also don't get these on my Mac Pro ???

(See full trace by running task with --trace)
jake@mbp-3 : ccls_engine 555> ruby -v
ruby 1.8.7 (2010-08-16 patchlevel 302) [i686-darwin9.8.0]

ArgumentError: wrong number of arguments (1 for 0)
  app/models/search.rb:183:in `flatten'
  app/models/search.rb:183:in `having_options'
  app/models/search.rb:175:in `having'
  app/models/study_subject_search.rb:46:in `study_subjects'

ArgumentError: odd number of arguments for Hash
  app/models/abstract.rb:301:in `[]'
  app/models/abstract.rb:301:in `comparable_attributes'
  app/models/abstract.rb:309:in `diff'
  app/models/abstract.rb:305:in `is_the_same_as?'

Ccls/Pii should return join of mother's name: .
DEPRECATION WARNING: String#chars has been deprecated in favor of String#mb_chars. (called from initials at /Users/jake/github_repo/ccls/ccls_engine/app/models/pii.rb:57)

test_@@_should_get_new_with_superuser_login(Ccls::RefusalReasonsControllerTest):
ActionView::TemplateError: undefined method `find_index' for [:code]:Array
  On line #4 of app/views/refusal_reasons/_form.html.erb

Some general ActiveRecord model notes:¶ ↑

Don’t have validations that could raise errors that the user can’t do anything about.

When using validates_presence_of, use allow_blank => true on other validations to avoid multiple errors if blank.

When validating the presence of associations, validate on foreign key rather than association so that the error shows up correctly in view. Unfortunately, this will not guarantee that an association actually exists with that id as it would if the validation was on the association.

validates_presence_of :project ( will not raise error on project_id so in the view, the project_id selector won't have an error and so won't be highlighted like other errors will be.)
validates_presence_of :project_id ( will not ensure that an actual project for the given id exists, but will show the error correctly in the view. )

I would like to have a validation that ensures that the _id is legitimate.  I do not think that validates_associated is what I want.  Having the both does what I want, but then the view will show "Project is blank" twice.

This seems to work …

validates_presence_of :project, :if => :project_id
validates_presence_of :project_id

… but is a bit of a misnomer. The association validation will raise a ‘blank’ error, rather than a more appropriate ‘non-existant’ error, although the message could be altered.

Still some models and associations may need done due to priorities and the fact that some never end up in a view and the association may be problematic. (Aliquot,HomexOutcome,Patient)

Some general ActiveSupport::TestCase unit test notes:¶ ↑

Most, if not all, of the ‘class level’ assertions are defined in ccls-common_lib. They call ‘create_object’, which, unless explicitly defined, is handled in a method_missing handler which extracts the model name from the testing class and uses the factory of the same name. (ie. AbstractTest -> Factory(:abstract) ) In addition, this same method missing handler is used for handling undefined methods like ‘create_abstract’. The handler takes this method which matches /create_(.*)/ and calls a Factory($1)

Also note, create_object only works in unit tests as they are generally associated with a particular model. Controllers, on the other hand, do not share this privilege as they are not. The create_MODEL_NAME technique does still work.

These create_* methods call Factory.build and then save. This is predominantly because by default Factory uses create! which raises errors rather than returning false which makes testing the error difficult. I think that there is a way to set the “default_strategy” for factory_girl, but I’ve yet to figure that out.

Required Gem Sources¶ ↑

gem sources -a http://rubygems.org
gem sources -a http://gems.github.com

Required Gems¶ ↑

Installation (as a gem/plugin/engine)¶ ↑

In your config/environment.rb

config.gem 'ccls-ccls_engine'

Generate an initializer and copy in some files.

script/generate ccls_engine

( why don’t I copy in these yml files, or at least their examples? )

Also need to manually add a shared_database.yml with matching configuration.

cp config/shared_database.yml.example config/shared_database.yml

Production Installation¶ ↑

Initial database setup (should already be done so don’t do this)

drop the shared production database
create the shared production database
rake db:migrate RAILS_ENV=production

# import all the test AND production fixtures
rake ccls:full_update RAILS_ENV=production

# DESTRUCTIVE.  Destroy existing data and parse the csv
# files on the "S Drive". These tasks should be
# commented out to prevent this from happening.
rake odms_import:csv_data

Production Updating¶ ↑

git pull
#	No longer uses the Gemfile as it meddled with the gem creation.
#	Should link the Gemfile.tmp to Gemfile in home dir.
bundle update	
rake db:migrate RAILS_ENV=production

Testing¶ ↑

rake db:migrate
rake test and/or autotest

Gemified with Jeweler¶ ↑

vi Rakefile
rake version:write

rake version:bump:patch
rake version:bump:minor
rake version:bump:major

rake gemspec

rake install
rake release

Copyright © 2010 [Jake Wendt], released under the MIT license