Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Compatibility with rails-3.0.0.beta and improved README

  • Loading branch information...
commit b10aee7466f462403b05eb0a39994e8dba81c953 1 parent fa6f441
@snusnu authored
View
4 .gitignore
@@ -1,3 +1,7 @@
+.bundle
db/*.sqlite3
log/*.log
tmp/**/*
+vendor
+!vendor/cache
+
View
55 Gemfile
@@ -1,35 +1,20 @@
-disable_system_gems
-disable_rubygems
-
-do_version = '0.10.1'
-
-gem 'rails', :git => "git://github.com/rails/rails.git"
-gem 'arel', :git => "git://github.com/rails/arel.git"
-gem 'rack', '~> 1.1'
-
-gem 'dm-core', :git => 'git://github.com/snusnu/dm-core.git'
-
-gem 'data_objects', do_version
-gem 'do_mysql', do_version
-
-git "git://github.com/snusnu/dm-more.git" do
-
- gem 'dm-types', :path => 'dm-types'
- gem 'dm-validations', :path => 'dm-validations'
- gem 'dm-serializer', :path => 'dm-serializer'
- gem 'dm-constraints', :path => 'dm-constraints'
- gem 'dm-aggregates', :path => 'dm-aggregates'
- gem 'dm-timestamps', :path => 'dm-timestamps'
- gem 'dm-observer', :path => 'dm-observer'
- gem 'dm-migrations', :path => 'dm-migrations'
-
-end
-
-gem 'rails3_datamapper', :git => 'git://github.com/dkubb/rails3_datamapper.git'
-
-only :test do
-
- gem 'rspec', '~> 1.3'
- gem 'do_sqlite3', do_version
-
-end
+source 'http://gemcutter.org'
+
+gem 'rails', '3.0.0.beta'
+
+gem 'data_objects', '0.10.1'
+gem 'do_mysql', '0.10.1'
+
+git 'git://github.com/snusnu/dm-core.git', 'branch' => 'active_support'
+git "git://github.com/snusnu/dm-more.git", 'branch' => 'active_support'
+git 'git://github.com/dkubb/rails3_datamapper.git'
+
+gem 'dm-core'
+gem 'dm-types'
+gem 'dm-validations'
+gem 'dm-constraints'
+gem 'dm-aggregates'
+gem 'dm-timestamps'
+gem 'dm-migrations'
+gem 'dm-observer'
+gem 'rails3_datamapper'
View
243 README
@@ -0,0 +1,243 @@
+== Welcome to Rails
+
+Rails is a web-application framework that includes everything needed to create
+database-backed web applications according to the Model-View-Control pattern.
+
+This pattern splits the view (also called the presentation) into "dumb" templates
+that are primarily responsible for inserting pre-built data in between HTML tags.
+The model contains the "smart" domain objects (such as Account, Product, Person,
+Post) that holds all the business logic and knows how to persist themselves to
+a database. The controller handles the incoming requests (such as Save New Account,
+Update Product, Show Post) by manipulating the model and directing data to the view.
+
+In Rails, the model is handled by what's called an object-relational mapping
+layer entitled Active Record. This layer allows you to present the data from
+database rows as objects and embellish these data objects with business logic
+methods. You can read more about Active Record in
+link:files/vendor/rails/activerecord/README.html.
+
+The controller and view are handled by the Action Pack, which handles both
+layers by its two parts: Action View and Action Controller. These two layers
+are bundled in a single package due to their heavy interdependence. This is
+unlike the relationship between the Active Record and Action Pack that is much
+more separate. Each of these packages can be used independently outside of
+Rails. You can read more about Action Pack in
+link:files/vendor/rails/actionpack/README.html.
+
+
+== Getting Started
+
+1. At the command prompt, start a new Rails application using the <tt>rails</tt> command
+ and your application name. Ex: rails myapp
+2. Change directory into myapp and start the web server: <tt>script/server</tt> (run with --help for options)
+3. Go to http://localhost:3000/ and get "Welcome aboard: You're riding the Rails!"
+4. Follow the guidelines to start developing your application
+
+
+== Web Servers
+
+By default, Rails will try to use Mongrel if it's are installed when started with script/server, otherwise Rails will use WEBrick, the webserver that ships with Ruby. But you can also use Rails
+with a variety of other web servers.
+
+Mongrel is a Ruby-based webserver with a C component (which requires compilation) that is
+suitable for development and deployment of Rails applications. If you have Ruby Gems installed,
+getting up and running with mongrel is as easy as: <tt>gem install mongrel</tt>.
+More info at: http://mongrel.rubyforge.org
+
+Say other Ruby web servers like Thin and Ebb or regular web servers like Apache or LiteSpeed or
+Lighttpd or IIS. The Ruby web servers are run through Rack and the latter can either be setup to use
+FCGI or proxy to a pack of Mongrels/Thin/Ebb servers.
+
+== Apache .htaccess example for FCGI/CGI
+
+# General Apache options
+AddHandler fastcgi-script .fcgi
+AddHandler cgi-script .cgi
+Options +FollowSymLinks +ExecCGI
+
+# If you don't want Rails to look in certain directories,
+# use the following rewrite rules so that Apache won't rewrite certain requests
+#
+# Example:
+# RewriteCond %{REQUEST_URI} ^/notrails.*
+# RewriteRule .* - [L]
+
+# Redirect all requests not available on the filesystem to Rails
+# By default the cgi dispatcher is used which is very slow
+#
+# For better performance replace the dispatcher with the fastcgi one
+#
+# Example:
+# RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
+RewriteEngine On
+
+# If your Rails application is accessed via an Alias directive,
+# then you MUST also set the RewriteBase in this htaccess file.
+#
+# Example:
+# Alias /myrailsapp /path/to/myrailsapp/public
+# RewriteBase /myrailsapp
+
+RewriteRule ^$ index.html [QSA]
+RewriteRule ^([^.]+)$ $1.html [QSA]
+RewriteCond %{REQUEST_FILENAME} !-f
+RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
+
+# In case Rails experiences terminal errors
+# Instead of displaying this message you can supply a file here which will be rendered instead
+#
+# Example:
+# ErrorDocument 500 /500.html
+
+ErrorDocument 500 "<h2>Application error</h2>Rails application failed to start properly"
+
+
+== Debugging Rails
+
+Sometimes your application goes wrong. Fortunately there are a lot of tools that
+will help you debug it and get it back on the rails.
+
+First area to check is the application log files. Have "tail -f" commands running
+on the server.log and development.log. Rails will automatically display debugging
+and runtime information to these files. Debugging info will also be shown in the
+browser on requests from 127.0.0.1.
+
+You can also log your own messages directly into the log file from your code using
+the Ruby logger class from inside your controllers. Example:
+
+ class WeblogController < ActionController::Base
+ def destroy
+ @weblog = Weblog.find(params[:id])
+ @weblog.destroy
+ logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
+ end
+ end
+
+The result will be a message in your log file along the lines of:
+
+ Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1
+
+More information on how to use the logger is at http://www.ruby-doc.org/core/
+
+Also, Ruby documentation can be found at http://www.ruby-lang.org/ including:
+
+* The Learning Ruby (Pickaxe) Book: http://www.ruby-doc.org/docs/ProgrammingRuby/
+* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
+
+These two online (and free) books will bring you up to speed on the Ruby language
+and also on programming in general.
+
+
+== Debugger
+
+Debugger support is available through the debugger command when you start your Mongrel or
+Webrick server with --debugger. This means that you can break out of execution at any point
+in the code, investigate and change the model, AND then resume execution!
+You need to install ruby-debug to run the server in debugging mode. With gems, use 'gem install ruby-debug'
+Example:
+
+ class WeblogController < ActionController::Base
+ def index
+ @posts = Post.find(:all)
+ debugger
+ end
+ end
+
+So the controller will accept the action, run the first line, then present you
+with a IRB prompt in the server window. Here you can do things like:
+
+ >> @posts.inspect
+ => "[#<Post:0x14a6be8 @attributes={\"title\"=>nil, \"body\"=>nil, \"id\"=>\"1\"}>,
+ #<Post:0x14a6620 @attributes={\"title\"=>\"Rails you know!\", \"body\"=>\"Only ten..\", \"id\"=>\"2\"}>]"
+ >> @posts.first.title = "hello from a debugger"
+ => "hello from a debugger"
+
+...and even better is that you can examine how your runtime objects actually work:
+
+ >> f = @posts.first
+ => #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
+ >> f.
+ Display all 152 possibilities? (y or n)
+
+Finally, when you're ready to resume execution, you enter "cont"
+
+
+== Console
+
+You can interact with the domain model by starting the console through <tt>script/console</tt>.
+Here you'll have all parts of the application configured, just like it is when the
+application is running. You can inspect domain models, change values, and save to the
+database. Starting the script without arguments will launch it in the development environment.
+Passing an argument will specify a different environment, like <tt>script/console production</tt>.
+
+To reload your controllers and models after launching the console run <tt>reload!</tt>
+
+== dbconsole
+
+You can go to the command line of your database directly through <tt>script/dbconsole</tt>.
+You would be connected to the database with the credentials defined in database.yml.
+Starting the script without arguments will connect you to the development database. Passing an
+argument will connect you to a different database, like <tt>script/dbconsole production</tt>.
+Currently works for mysql, postgresql and sqlite.
+
+== Description of Contents
+
+app
+ Holds all the code that's specific to this particular application.
+
+app/controllers
+ Holds controllers that should be named like weblogs_controller.rb for
+ automated URL mapping. All controllers should descend from ApplicationController
+ which itself descends from ActionController::Base.
+
+app/models
+ Holds models that should be named like post.rb.
+ Most models will descend from ActiveRecord::Base.
+
+app/views
+ Holds the template files for the view that should be named like
+ weblogs/index.html.erb for the WeblogsController#index action. All views use eRuby
+ syntax.
+
+app/views/layouts
+ Holds the template files for layouts to be used with views. This models the common
+ header/footer method of wrapping views. In your views, define a layout using the
+ <tt>layout :default</tt> and create a file named default.html.erb. Inside default.html.erb,
+ call <% yield %> to render the view using this layout.
+
+app/helpers
+ Holds view helpers that should be named like weblogs_helper.rb. These are generated
+ for you automatically when using script/generate for controllers. Helpers can be used to
+ wrap functionality for your views into methods.
+
+config
+ Configuration files for the Rails environment, the routing map, the database, and other dependencies.
+
+db
+ Contains the database schema in schema.rb. db/migrate contains all
+ the sequence of Migrations for your schema.
+
+doc
+ This directory is where your application documentation will be stored when generated
+ using <tt>rake doc:app</tt>
+
+lib
+ Application specific libraries. Basically, any kind of custom code that doesn't
+ belong under controllers, models, or helpers. This directory is in the load path.
+
+public
+ The directory available for the web server. Contains subdirectories for images, stylesheets,
+ and javascripts. Also contains the dispatchers and the default HTML files. This should be
+ set as the DOCUMENT_ROOT of your web server.
+
+script
+ Helper scripts for automation and generation.
+
+test
+ Unit and functional tests along with fixtures. When using the script/generate scripts, template
+ test files will be generated for you and placed in this directory.
+
+vendor
+ External libraries that the application depends on. Also includes the plugins subdirectory.
+ If the app has frozen rails, those gems also go here, under vendor/rails/.
+ This directory is in the load path.
View
336 README.rdoc
@@ -1,296 +1,148 @@
-== Welcome to datamapper on Rails 3
+== Welcome to datamapper on Rails 3 (beta)
+
+Getting {datamapper}[http://github.com/datamapper/dm-core] up and running on rails3 is really easy. It won't take longer than 5 minutes, really :) Here's how:
+
+To get started you only need to issue a few simple commands. These will install a bundled environment consisting of everything that is needed to run this app. Currently I only succeeded using {rails-3.0.0.beta}[http://github.com/rails/rails] but hopefully I will be able to find out how to support rails master from git too. I haven't yet figured out how to that with {bundler}[http://github.com/carlhuda/bundler].
+
+These are the commands to get you going in no more than 5 minutes.
gem install bundler
git clone git://github.com/snusnu/datamapper_on_rails3.git
cd datamapper_on_rails3
- gem bundle
+ bundle install
bin/rake db:create
bin/rake db:automigrate
- ./script/server
+ bundle exec rails server
open http://localhost:3000/people
-You should see rails3 serving an empty list of people waiting to be added
-
-== Current Issues
-
-To work around an issue with bundler-0.8.1 which doesn't currently support
-dependencies from git with a :branch option specified, here's what you need
-to do (This will not be necessary once my changes are merged into dm-core)
-
- cd vendor/gems/ruby/1.8/dirs/dm-core
- git checkout master (workaround a bug in bundler that leaves us on no-branch)
- git checkout -b active_support --track origin/active_support
-
-This is necessary to have dm-core running with active_support-3.0.pre
-
-Additionally, it seems necessary to patch rails in one place in order to be able to run with
-
- disable_system_gems
- disable_rubygems
-
-although I guess this is probably a bundler issue. What you have to do is make http://github.com/rails/rails/blob/master/railties/lib/rails/backtrace_cleaner.rb#L34 read something like:
-
- (Array(Gem.path) + [Gem.default_dir]).uniq.each do |path|
-
-if you're seeing the following error:
-
- .../activesupport/lib/active_support/core_ext/string/output_safety.rb:28:in `original_plus'
- .../activesupport/lib/active_support/core_ext/string/output_safety.rb:28:in `+'
- .../railties/lib/rails/backtrace_cleaner.rb:34:in `add_gem_filters'
- ...
-
-This will help you if you for example try to access a non existing resource
-
- /people/100
-
-and rails simply tells you
-
- Error during failsafe response: can't convert Array into String
-
-Hopefully this will get fixed upstream soon. In the meantime, skipping _disable_rubygems_ maybe works around that too. Honestly, I was too lazy to try.
-
-Additionally, you might want to patch your bundled rails like http://github.com/woodie did at http://gist.github.com/266649 This will provide you with at least some information of what actually went wrong.
+You should now see rails3 serving an empty list of people. Feel free to add some.
-== Welcome to Rails
+Additionally, you should have the following commands available since rails3 should be successfully installed.
-Rails is a web-application framework that includes everything needed to create
-database-backed web applications according to the Model-View-Control pattern.
+ snusnu$ bundle exec rails
+ Usage: rails COMMAND [ARGS]
-This pattern splits the view (also called the presentation) into "dumb" templates
-that are primarily responsible for inserting pre-built data in between HTML tags.
-The model contains the "smart" domain objects (such as Account, Product, Person,
-Post) that holds all the business logic and knows how to persist themselves to
-a database. The controller handles the incoming requests (such as Save New Account,
-Update Product, Show Post) by manipulating the model and directing data to the view.
+ The most common rails commands are:
+ generate Generate new code (short-cut alias: "g")
+ console Start the Rails console (short-cut alias: "c")
+ server Start the Rails server (short-cut alias: "s")
+ dbconsole Start a console for the database specified in config/database.yml
+ (short-cut alias: "db")
-In Rails, the model is handled by what's called an object-relational mapping
-layer entitled Active Record. This layer allows you to present the data from
-database rows as objects and embellish these data objects with business logic
-methods. You can read more about Active Record in
-link:files/vendor/rails/activerecord/README.html.
+ In addition to those, there are:
+ application Generate the Rails application code
+ destroy Undo code generated with "generate"
+ benchmarker See how fast a piece of code runs
+ profiler Get profile information from a piece of code
+ plugin Install a plugin
+ runner Run a piece of code in the application environment
-The controller and view are handled by the Action Pack, which handles both
-layers by its two parts: Action View and Action Controller. These two layers
-are bundled in a single package due to their heavy interdependence. This is
-unlike the relationship between the Active Record and Action Pack that is much
-more separate. Each of these packages can be used independently outside of
-Rails. You can read more about Action Pack in
-link:files/vendor/rails/actionpack/README.html.
+ All commands can be run with -h for more information.
-== Getting Started
+== Available datamapper specific generators
-1. At the command prompt, start a new Rails application using the <tt>rails</tt> command
- and your application name. Ex: rails myapp
-2. Change directory into myapp and start the web server: <tt>script/server</tt> (run with --help for options)
-3. Go to http://localhost:3000/ and get "Welcome aboard: You're riding the Rails!"
-4. Follow the guidelines to start developing your application
+The following generators are available to help you get started with some common components of any rails application. The list of these will probably grow over time. To invoke a generator simply issue one or all of the following inside Rails.root
+ bundle exec rails generate data_mapper:model Project name:string
+ bundle exec rails generate data_mapper:observer Project
-== Web Servers
+ # TODO This still needs some fixes
+ bundle exec rails generate data_mapper:migration
-By default, Rails will try to use Mongrel if it's are installed when started with script/server, otherwise Rails will use WEBrick, the webserver that ships with Ruby. But you can also use Rails
-with a variety of other web servers.
-Mongrel is a Ruby-based webserver with a C component (which requires compilation) that is
-suitable for development and deployment of Rails applications. If you have Ruby Gems installed,
-getting up and running with mongrel is as easy as: <tt>gem install mongrel</tt>.
-More info at: http://mongrel.rubyforge.org
+== Standard generators we get for free
-Say other Ruby web servers like Thin and Ebb or regular web servers like Apache or LiteSpeed or
-Lighttpd or IIS. The Ruby web servers are run through Rack and the latter can either be setup to use
-FCGI or proxy to a pack of Mongrels/Thin/Ebb servers.
+Due to the awesomeness of rails3 generators we get some cool generators for free. Since the new generators provide hooks that allow the rails3_datamapper gem to provide generators that hook into parts like model, scaffolds or test generation, everything just works like it would with active_record.
-== Apache .htaccess example for FCGI/CGI
+ bundle exec rails generate scaffold Project name:string
+ bundle exec rails destroy scaffold Project
-# General Apache options
-AddHandler fastcgi-script .fcgi
-AddHandler cgi-script .cgi
-Options +FollowSymLinks +ExecCGI
+Well, everything isn't exactly true currently. I haven't yet played with rspec generators, but this is already on the TODO list.
-# If you don't want Rails to look in certain directories,
-# use the following rewrite rules so that Apache won't rewrite certain requests
-#
-# Example:
-# RewriteCond %{REQUEST_URI} ^/notrails.*
-# RewriteRule .* - [L]
-# Redirect all requests not available on the filesystem to Rails
-# By default the cgi dispatcher is used which is very slow
-#
-# For better performance replace the dispatcher with the fastcgi one
-#
-# Example:
-# RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
-RewriteEngine On
+== Available datamapper specific rake tasks
-# If your Rails application is accessed via an Alias directive,
-# then you MUST also set the RewriteBase in this htaccess file.
-#
-# Example:
-# Alias /myrailsapp /path/to/myrailsapp/public
-# RewriteBase /myrailsapp
+To get a list of all available rake tasks in your rails3 app, issue the usual
-RewriteRule ^$ index.html [QSA]
-RewriteRule ^([^.]+)$ $1.html [QSA]
-RewriteCond %{REQUEST_FILENAME} !-f
-RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
+ rake -T
-# In case Rails experiences terminal errors
-# Instead of displaying this message you can supply a file here which will be rendered instead
-#
-# Example:
-# ErrorDocument 500 /500.html
+The following is an excerpt of the datamapper specific rake tasks that the rails3_datamapper gem adds for us.
-ErrorDocument 500 "<h2>Application error</h2>Rails application failed to start properly"
-
-
-== Debugging Rails
-
-Sometimes your application goes wrong. Fortunately there are a lot of tools that
-will help you debug it and get it back on the rails.
-
-First area to check is the application log files. Have "tail -f" commands running
-on the server.log and development.log. Rails will automatically display debugging
-and runtime information to these files. Debugging info will also be shown in the
-browser on requests from 127.0.0.1.
-
-You can also log your own messages directly into the log file from your code using
-the Ruby logger class from inside your controllers. Example:
-
- class WeblogController < ActionController::Base
- def destroy
- @weblog = Weblog.find(params[:id])
- @weblog.destroy
- logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
- end
- end
-
-The result will be a message in your log file along the lines of:
-
- Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1
-
-More information on how to use the logger is at http://www.ruby-doc.org/core/
-
-Also, Ruby documentation can be found at http://www.ruby-lang.org/ including:
-
-* The Learning Ruby (Pickaxe) Book: http://www.ruby-doc.org/docs/ProgrammingRuby/
-* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
-
-These two online (and free) books will bring you up to speed on the Ruby language
-and also on programming in general.
-
-
-== Debugger
-
-Debugger support is available through the debugger command when you start your Mongrel or
-Webrick server with --debugger. This means that you can break out of execution at any point
-in the code, investigate and change the model, AND then resume execution!
-You need to install ruby-debug to run the server in debugging mode. With gems, use 'gem install ruby-debug'
-Example:
-
- class WeblogController < ActionController::Base
- def index
- @posts = Post.find(:all)
- debugger
- end
- end
-
-So the controller will accept the action, run the first line, then present you
-with a IRB prompt in the server window. Here you can do things like:
+ ...
+ rake db:automigrate # Perform destructive automigration
+ rake db:autoupgrade # Perform non destructive automigration
+ rake db:create # Create the database defined in config/database.yml for the current Rails.env - also creates the test database if Rails.env.development?
+ rake db:create:all # Create all the local databases defined in config/database.yml
+ rake db:drop # Drops the database for the current Rails.env
+ rake db:drop:all # Drop all the local databases defined in config/database.yml
+ rake db:migrate # Migrate the database to the latest version
+ rake db:migrate:down[version] # Migrate down using migrations
+ rake db:migrate:up[version] # Migrate up using migrations
+ rake db:seed # Load the seed data from db/seeds.rb
+ rake db:sessions:clear # Clear the sessions table for DataMapperStore
+ rake db:sessions:create # Creates the sessions table for DataMapperStore
+ rake db:setup # Create the database, load the schema, and initialize with the seed data
+ ...
- >> @posts.inspect
- => "[#<Post:0x14a6be8 @attributes={\"title\"=>nil, \"body\"=>nil, \"id\"=>\"1\"}>,
- #<Post:0x14a6620 @attributes={\"title\"=>\"Rails you know!\", \"body\"=>\"Only ten..\", \"id\"=>\"2\"}>]"
- >> @posts.first.title = "hello from a debugger"
- => "hello from a debugger"
-...and even better is that you can examine how your runtime objects actually work:
+== Identity Map support
- >> f = @posts.first
- => #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
- >> f.
- Display all 152 possibilities? (y or n)
+By default, rails3_datamapper enables the use of the {identity map}[http://datamapper.org/why.html]. If for any reason you want to turn that off, just add the following line to your config/application.rb or config/environments/*.rb file.
-Finally, when you're ready to resume execution, you enter "cont"
+ config.data_mapper.use_identity_map = false
-== Console
+== Using additional datamapper plugins
-You can interact with the domain model by starting the console through <tt>script/console</tt>.
-Here you'll have all parts of the application configured, just like it is when the
-application is running. You can inspect domain models, change values, and save to the
-database. Starting the script without arguments will launch it in the development environment.
-Passing an argument will specify a different environment, like <tt>script/console production</tt>.
+In order to use additional plugins add them to the Gemfile and require them from inside a file in config/initializers. Once you've done that, update your bundle and you should be ready to use the plugin(s)
-To reload your controllers and models after launching the console run <tt>reload!</tt>
+ cd /path/to/your/app
+ edit Gemfile and add requires to your config/initializers/data_mapper_plugins
+ bundle install vendor
-== dbconsole
+Have a look of this application's {Gemfile}[http://github.com/snusnu/datamapper_on_rails3/blob/master/Gemfile] for an idea of how to use gems from git repositories.
-You can go to the command line of your database directly through <tt>script/dbconsole</tt>.
-You would be connected to the database with the credentials defined in database.yml.
-Starting the script without arguments will connect you to the development database. Passing an
-argument will connect you to a different database, like <tt>script/dbconsole production</tt>.
-Currently works for mysql, postgresql and sqlite.
-== Description of Contents
+== Rails notification system
-app
- Holds all the code that's specific to this particular application.
+Currently rails3_datamapper publishes the same benchmarking information like active_record does. This means that you will get output like this in your log files.
-app/controllers
- Holds controllers that should be named like weblogs_controller.rb for
- automated URL mapping. All controllers should descend from ApplicationController
- which itself descends from ActionController::Base.
+ Completed in 9ms (Views: 7.6ms | DataMapper: 0.6ms) with 200
-app/models
- Holds models that should be named like post.rb.
- Most models will descend from ActiveRecord::Base.
+While the SQL issued by DO adapters is already being logged properly, it is not yet published to possible rails subscribers. This is basically the only thing we're still missing in terms of datamapper rails3 notifications integration, compared with active_record. Of course we're not tied to only publishing these messages. If anyone can think of other useful information to publish, it's easy to hook into rails' notification system.
-app/views
- Holds the template files for the view that should be named like
- weblogs/index.html.erb for the WeblogsController#index action. All views use eRuby
- syntax.
-app/views/layouts
- Holds the template files for layouts to be used with views. This models the common
- header/footer method of wrapping views. In your views, define a layout using the
- <tt>layout :default</tt> and create a file named default.html.erb. Inside default.html.erb,
- call <% yield %> to render the view using this layout.
+== Current Issues
-app/helpers
- Holds view helpers that should be named like weblogs_helper.rb. These are generated
- for you automatically when using script/generate for controllers. Helpers can be used to
- wrap functionality for your views into methods.
+ No JS framework is picked yet and prototype was excluded when generating the app
+ Currently hitting the 'Destroy' link in default forms issues a GET /person/id.
+ Obviously this won't have the desired effect.
-config
- Configuration files for the Rails environment, the routing map, the database, and other dependencies.
-db
- Contains the database schema in schema.rb. db/migrate contains all
- the sequence of Migrations for your schema.
+== TODO (not necessarily in that order)
-doc
- This directory is where your application documentation will be stored when generated
- using <tt>rake doc:app</tt>
+ SPECS !!!
+ Further README updates
+ Further {rails3_datamapper}[http://github.com/dkubb/rails3_datamapper] improvements
+ Check if the {session store}[http://github.com/dkubb/rails3_datamapper/blob/master/lib/rails3_datamapper/session_store.rb] support works
+ rspec-2.0.0 (generator) support
+ jQuery support (fixes current Issues with 'Destroy' action)
+ Provide a rails template for generating tailored apps for datamapper
+ Publish SQL issued by DO (and eventually every adapter) to rails subscribers
+ Think about integrating with {dana}[http://github.com/snusnu/dm-accepts_nested_attributes]
+ Think about integrating {dm-serializer}[http://github.com/datamapper/dm-more/tree/master/dm-serializer/]
+ Make this app do something useful!
-lib
- Application specific libraries. Basically, any kind of custom code that doesn't
- belong under controllers, models, or helpers. This directory is in the load path.
-public
- The directory available for the web server. Contains subdirectories for images, stylesheets,
- and javascripts. Also contains the dispatchers and the default HTML files. This should be
- set as the DOCUMENT_ROOT of your web server.
+== Credits
-script
- Helper scripts for automation and generation.
+Big thanks to everyone working on {datamapper}[http://github.com/datamapper/dm-core], {rails}[http://github.com/rails/rails], {bundler}[http://github.com/carlhuda/bundler] and open source in general. This will be (and actually already is) an awesome platform for developing web applications.
-test
- Unit and functional tests along with fixtures. When using the script/generate scripts, template
- test files will be generated for you and placed in this directory.
+== Note on Patches/Pull Requests
-vendor
- External libraries that the application depends on. Also includes the plugins subdirectory.
- If the app has frozen rails, those gems also go here, under vendor/rails/.
- This directory is in the load path.
+ Fork the project.
+ Make your feature addition or bug fix.
+ Add tests for it. This is important so I don’t break it in a future version unintentionally.
+ Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
+ Send me a pull request. Bonus points for topic branches.
View
2  Rakefile
@@ -7,4 +7,4 @@ require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
-RailsApp::Application.load_tasks
+Rails::Application.load_tasks
View
2  config.ru
@@ -1,4 +1,4 @@
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
-run RailsApp::Application.instance
+run DatamapperOnRails3::Application
View
18 config/application.rb
@@ -1,6 +1,16 @@
require File.expand_path('../boot', __FILE__)
-module RailsApp
+# Pick the frameworks you want:
+require "action_controller/railtie"
+require "rails3_datamapper/railtie"
+require "action_mailer/railtie"
+# require "active_resource/railtie"
+# require "rails/test_unit/railtie"
+
+# Auto-require default libraries and those for the current Rails environment.
+Bundler.require :default, Rails.env
+
+module DatamapperOnRails3
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
@@ -25,13 +35,13 @@ class Application < Rails::Application
# config.i18n.default_locale = :de
# Configure generators values. Many other options are available, be sure to check the documentation.
-
- config.filter_parameters = :password
-
config.generators do |g|
g.orm :data_mapper, :migration => true
g.template_engine :erb
+ #g.test_framework :rspec, :fixture => true
end
+ # Configure sensitive parameters which will be filtered from the log file.
+ config.filter_parameters << :password
end
end
View
32 config/boot.rb
@@ -1,19 +1,17 @@
# Use Bundler (preferred)
-environment = File.expand_path('../../vendor/gems/environment', __FILE__)
-if File.exist?("#{environment}.rb")
- require environment
-else
- # I deliberately deleted the originally generated
- # codepath because I don't need or want it anyway.
- puts "ERROR: Not running from bundled environment!"
-end
-
+begin
+ require File.expand_path('../../.bundle/environment', __FILE__)
+rescue LoadError
+ require 'rubygems'
+ require 'bundler'
+ Bundler.setup
-# To pick the frameworks you want, remove 'require "rails/all"'
-# and list the framework railties that you want:
-
-require "action_controller/railtie"
-require "action_view/railtie"
-require "action_mailer/railtie"
-require "active_model/railtie"
-require "rails3_datamapper"
+ # To use 2.x style vendor/rails and RubyGems
+ #
+ # vendor_rails = File.expand_path('../../vendor/rails', __FILE__)
+ # if File.exist?(vendor_rails)
+ # Dir["#{vendor_rails}/*/lib"].each { |path| $:.unshift(path) }
+ # end
+ #
+ # require 'rubygems'
+end
View
6 config/database.yml
@@ -5,13 +5,13 @@ defaults: &defaults
host: localhost
development:
- database: rails3_development
+ database: datamapper_on_rails3_development
<<: *defaults
test:
- database: rails3_test
+ database: datamapper_on_rails3_test
<<: *defaults
production:
- database: rails3_production
+ database: datamapper_on_rails3_production
<<: *defaults
View
2  config/environment.rb
@@ -2,4 +2,4 @@
require File.expand_path('../application', __FILE__)
# Initialize the rails application
-RailsApp::Application.initialize!
+DatamapperOnRails3::Application.initialize!
View
8 config/environments/development.rb
@@ -1,4 +1,4 @@
-RailsApp::Application.configure do
+DatamapperOnRails3::Application.configure do
# Settings specified here will take precedence over those in config/environment.rb
# In the development environment your application's code is reloaded on
@@ -10,9 +10,9 @@
config.whiny_nils = true
# Show full error reports and disable caching
- config.action_controller.consider_all_requests_local = true
- config.action_view.debug_rjs = true
- config.action_controller.perform_caching = false
+ config.consider_all_requests_local = true
+ config.action_view.debug_rjs = true
+ config.action_controller.perform_caching = false
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false
View
8 config/environments/production.rb
@@ -1,4 +1,4 @@
-RailsApp::Application.configure do
+DatamapperOnRails3::Application.configure do
# Settings specified here will take precedence over those in config/environment.rb
# The production environment is meant for finished, "live" apps.
@@ -6,8 +6,8 @@
config.cache_classes = true
# Full error reports are disabled and caching is turned on
- config.action_controller.consider_all_requests_local = false
- config.action_controller.perform_caching = true
+ config.consider_all_requests_local = false
+ config.action_controller.perform_caching = true
# See everything in the log (default is :info)
# config.log_level = :debug
@@ -30,4 +30,4 @@
# Enable threaded mode
# config.threadsafe!
-end
+end
View
8 config/environments/test.rb
@@ -1,4 +1,4 @@
-RailsApp::Application.configure do
+DatamapperOnRails3::Application.configure do
# Settings specified here will take precedence over those in config/environment.rb
# The test environment is used exclusively to run your application's
@@ -11,8 +11,8 @@
config.whiny_nils = true
# Show full error reports and disable caching
- config.action_controller.consider_all_requests_local = true
- config.action_controller.perform_caching = false
+ config.consider_all_requests_local = true
+ config.action_controller.perform_caching = false
# Disable request forgery protection in test environment
config.action_controller.allow_forgery_protection = false
@@ -26,4 +26,4 @@
# This is necessary if your schema can't be completely dumped by the schema dumper,
# like if you have constraints or database-specific column types
# config.active_record.schema_format = :sql
-end
+end
View
2  config/initializers/backtrace_silencers.rb
@@ -4,4 +4,4 @@
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
-#Rails.backtrace_cleaner.remove_silencers!
+# Rails.backtrace_cleaner.remove_silencers!
View
2  config/initializers/cookie_verification_secret.rb
@@ -4,4 +4,4 @@
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
-ActionController::Base.cookie_verifier_secret = '87e2d431c5d917e3d01e59c3d0a991d7ed1166682c546bfdbf39828c58eb5866b406275db36b4494eceb03748165825bfe42f585b28cafd7d42a956e84c08f8f'
+ActionController::Base.cookie_verifier_secret = 'c7ef963cdfbbf6f8d1032e93f0d07ed9b5f3b2ab7af579cd320f513c1ecc38db70808442770f9c6487904cf7761121d1c65aa54a7375a1dc02d8b785f1ddbef4'
View
4 config/initializers/session_store.rb
@@ -5,8 +5,8 @@
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
ActionController::Base.session = {
- :key => '_rails_app_session',
- :secret => 'aad328bfa99fd6750d4b45e20b42c1c605b5052fb35de0ddfcd4d0ed5e7240f20524705f40e35a16a03469889dd74bc1a5a2ef49f78f1d0f7f556b69739602d2'
+ :key => '_datamapper_on_rails3_session',
+ :secret => '6a6d1472e25bd63de99d87b0d9d59703fa0ce51c026c20ecf35cf45aecceacf32ddfb7fc834e8906b6f5036417916fe7c34b313cdfeed09c7440c1e2b2778b0d'
}
# Use the database for sessions instead of the cookie-based default,
View
2  config/locales/en.yml
@@ -2,4 +2,4 @@
# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
en:
- hello: "Hello world"
+ hello: "Hello world"
View
11 config/routes.rb
@@ -1,13 +1,4 @@
-RailsApp::Application.routes.draw do |map|
-
- # FIXME
- #
- # This is really weird, maybe it has something to do with
- # Extlib::Inflection and active_support being both activated.
- # Another possibility is that dm-active_model still isn't really
- # active_model compliant. This definitely needs investigation
- #
- # In case it isn't obvious, that should read: resources :people
+DatamapperOnRails3::Application.routes.draw do |map|
resources :people
View
2  db/seeds.rb
@@ -2,6 +2,6 @@
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
-#
+#
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
# Mayor.create(:name => 'Daley', :city => cities.first)
View
2  public/index.html
@@ -255,7 +255,7 @@
<ol>
<li>
- <h2>Use <code>script/generate</code> to create your models and controllers</h2>
+ <h2>Use <code>rails generate</code> to create your models and controllers</h2>
<p>To see all available options, run it without parameters.</p>
</li>
View
10 script/rails
@@ -0,0 +1,10 @@
+#!/usr/bin/env ruby
+# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
+
+ENV_PATH = File.expand_path('../../config/environment', __FILE__)
+BOOT_PATH = File.expand_path('../../config/boot', __FILE__)
+APP_PATH = File.expand_path('../../config/application', __FILE__)
+ROOT_PATH = File.expand_path('../..', __FILE__)
+
+require BOOT_PATH
+require 'rails/commands'
Please sign in to comment.
Something went wrong with that request. Please try again.