<commit_before>= FreightTrain

==== FreightTrain is a DSL for representing collections that can be edited inline.

FreightTrain is especially useful for
- Rendering light-weight models as lists or tables
- Enabling users to create, update, and destroy objects with AJAX calls
- Editing objects' attributes using JavaScript without sending a request to the server

== Installation

For Rails 3:

    rails plugin install git://github.com/boblail/freight_train.git
    
For Rails 2:

    script/plugin install git://github.com/boblail/freight_train.git

To run on Rails 2, FreightTrain also requires {a backport of Rails 3's Responder}[http://github.com/boblail/rails3_responder].

Finally, the path `assets\javascripts\freight_train` contains JavaScripts that should be copied to your `public` path. I recommend symlinking the folder like this:

    cd public/javascripts; ln -s ../../vendor/plugins/freight_train/assets/javascripts/freight_train freight_train 

== Getting Started

=== Creating a sample application

Let's say we're creating a simple to-do list application:

    rails to-do-list; cd to-do-list
    rails generate scaffold ToDoItem description:string
    rake db:create db:migrate
    rails server
    
And you should be able to see the scaffolded app at {http://localhost:3000/to_do_items}[http://localhost:3000/to_do_items]. Add a few items so we can play with them later.

=== Setting up FreightTrain

Now let's see what FreightTrain can do. Install the plugin as described above. Then add `include FreightTrain` to your `ApplicationController`. Mine now looks like this:

    class ApplicationController < ActionController::Base
      include FreightTrain
      protect_from_forgery
    end 

...and the following JavaScript includes to your layout (`app/views/layouts/to_do_items.html.erb`):
<commit_msg>fixed double link in README<commit_after>= FreightTrain

==== FreightTrain is a DSL for representing collections that can be edited inline.

FreightTrain is especially useful for
- Rendering light-weight models as lists or tables
- Enabling users to create, update, and destroy objects with AJAX calls
- Editing objects' attributes using JavaScript without sending a request to the server

== Installation

For Rails 3:

    rails plugin install git://github.com/boblail/freight_train.git
    
For Rails 2:

    script/plugin install git://github.com/boblail/freight_train.git

To run on Rails 2, FreightTrain also requires {a backport of Rails 3's Responder}[http://github.com/boblail/rails3_responder].

Finally, the path `assets\javascripts\freight_train` contains JavaScripts that should be copied to your `public` path. I recommend symlinking the folder like this:

    cd public/javascripts; ln -s ../../vendor/plugins/freight_train/assets/javascripts/freight_train freight_train 

== Getting Started

=== Creating a sample application

Let's say we're creating a simple to-do list application:

    rails to-do-list; cd to-do-list
    rails generate scaffold ToDoItem description:string
    rake db:create db:migrate
    rails server
    
And you should be able to see the scaffolded app at http://localhost:3000/to_do_items. Add a few items so we can play with them later.

=== Setting up FreightTrain

Now let's see what FreightTrain can do. Install the plugin as described above. Then add `include FreightTrain` to your `ApplicationController`. Mine now looks like this:

    class ApplicationController < ActionController::Base
      include FreightTrain
      protect_from_forgery
    end 

...and the following JavaScript includes to your layout (`app/views/layouts/to_do_items.html.erb`):

{'fraction_non_alphanumeric': 0.07026729126481124, 'fraction_numerical': 0.00606227610912097, 'mean_word_length': 4.170940170940171, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4061299', 'n_tokens_mistral': 1076, 'n_tokens_neox': 966, 'n_words': 404}