Navigation Menu

Skip to content
This repository has been archived by the owner on Mar 26, 2023. It is now read-only.

Commit

Permalink
Update rails example for Rails 3.1.0 final.
Browse files Browse the repository at this point in the history
  • Loading branch information
pbm committed Sep 7, 2011
1 parent cd5715a commit 89c08d1
Show file tree
Hide file tree
Showing 17 changed files with 123 additions and 116 deletions.
2 changes: 0 additions & 2 deletions examples/rails/Gemfile
@@ -1,5 +1,3 @@
source 'http://w2-stdev-ub10-01.gemstone.com:9292'
source 'http://rubygems.org'

gem 'rails', '~>3.1'
gem 'bcrypt-ruby'
42 changes: 17 additions & 25 deletions examples/rails/README.rdoc
@@ -1,3 +1,12 @@


TODO: Bcrypt-Ruby gem issues:
* Could fix the ffi version
* Could get the maglev-bcrypt-ruby gem published
* Could encourage bcrypt-ruby to publish again



= Notes on MagLev and Rails 3

The files in this directory allow you to run the default Rails app on
Expand All @@ -15,8 +24,8 @@ GitHub.
$ rake maglev:start # or: $MAGLEV_HOME/bin/maglev start

2. Install Rails and patch it:
$ $MAGLEV_HOME/bin/gem install rails --pre
$ cd $MAGLEV_HOME/examples/rails
$ $MAGLEV_HOME/bin/bundle install
$ rake patch:activesupport

3. Setup the Database (see bottom of file for MySQL details):
Expand Down Expand Up @@ -44,35 +53,30 @@ Tutorial}[http://guides.rails.info/getting_started.html].
=== 1. Install rails

Install rails:
$ $MAGLEV_HOME/bin/gem install rails --version=3.1.0.rc4
$ cd $MAGLEV_HOME/examples/rails
$ $MAGLEV_HOME/bin/bundle install

You will need to patch activesupport. The patches directory has patches
for rails versions 3.0.0, 3.0.3, 3.0.4, 3.1.0rc4
for rails 3.1.0 and a few prior releases.
$ cd $MAGLEV_HOME/examples/rails
$ rake patch:activesupport

=== 2. Create and configure new rails app

Generate the application:
$ $MAGLEV_HOME/bin/rails new myapp
$ MAGLEV_HOME/bin/bundle exec rails new myapp

And configure the database:
$ cd myapp
$ $MAGLEV_HOME/bin/bundle exec $MAGLEV_HOME/bin/rake db:create

=== 3. Start server

$ cd myapp
$ $MAGLEV_HOME/bin/rails server

Static pages in the app load fine under MagLev: http://localhost:3000/
Simple dynamic pages work fine under MagLev: http://localhost:3000/rails/info/properties
$ $MAGLEV_HOME/bin/bundle rails server

=== 4. Generate new controllers and scaffolding

Run:
$ $MAGLEV_HOME/bin/rails generate controller home index
and generate the expected files.
$ $MAGLEV_HOME/bin/bundle rails generate controller home index

If you remove <tt>public/index.html</tt> and add the following into
<tt>config/routes.rb</tt>, you should be able to hit http://localhost:3000/
Expand All @@ -82,23 +86,12 @@ and see <tt>home#index</tt>
=== 5. More Scaffolding and Running migrations

You can also create scaffolding and run migrations:
$ $MAGLEV_HOME/bin/rails generate scaffold Post name:string title:string content:text
$ $MAGLEV_HOME/bin/bundle exec rails generate scaffold Post name:string title:string content:text
$ $MAGLEV_HOME/bin/rake db:migrate

You should now be able to start the server and hit
http://localhost:3000/posts and start managing your blog.

== Patch Details

The following patches are applied:
1. Patch changes the manner in which all subclasses are found. MagLev
does not support <tt>ObjectSpace#each_object</tt> (since objects may be
persisted, there can be hundreds of millions of them...). This patch allows
finding all subclasses currently loaded in a VM. The ActiveSupport file
already has patches for Rubinius and JRuby. We expect to submit this patch
to Rails.
2. There is a patch to workaround an include problem.

== MySQL details

To use MySQL, you'll have to use the ruby-mysql gem instead of the mysql2
Expand All @@ -124,4 +117,3 @@ Then run bundle:

$ cd myapp
$ $MAGLEV_HOME/bin/bundle install

3 changes: 1 addition & 2 deletions examples/rails/Rakefile
Expand Up @@ -16,8 +16,7 @@ namespace :patch do
"activesupport-3.0.4" => ['activesupport_class_patch.diff',
'activesupport_time_zone_patch.diff',
'activesupport_descendents_tracker_patch.diff'],
"activesupport-3.1.0" => ['activesupport_class_patch-3.1.diff',
'activesupport_time_patch-3.1.diff']
"activesupport-3.1.0" => ['activesupport_time_patch-3.1.diff']
}
apply_patches(patch_info)
end
Expand Down
15 changes: 9 additions & 6 deletions examples/rails/myapp/Gemfile
@@ -1,18 +1,21 @@
source 'http://w2-stdev-ub10-01.gemstone.com:9292'
source 'http://rubygems.org'

gem 'rails', '~>3.1'
gem 'rails', '3.1.0'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'sqlite3'

# Asset template engines
gem 'json'
gem 'sass-rails', "~> 3.1"
gem 'coffee-script'
gem 'uglifier'

# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', " ~> 3.1.0"
gem 'coffee-rails', "~> 3.1.0"
gem 'uglifier'
end

gem 'jquery-rails'

Expand Down
126 changes: 64 additions & 62 deletions examples/rails/myapp/Gemfile.lock
@@ -1,113 +1,115 @@
GEM
remote: http://rubygems.org/
specs:
actionmailer (3.1.0.rc4)
actionpack (= 3.1.0.rc4)
actionmailer (3.1.0)
actionpack (= 3.1.0)
mail (~> 2.3.0)
actionpack (3.1.0.rc4)
activemodel (= 3.1.0.rc4)
activesupport (= 3.1.0.rc4)
actionpack (3.1.0)
activemodel (= 3.1.0)
activesupport (= 3.1.0)
builder (~> 3.0.0)
erubis (~> 2.7.0)
i18n (~> 0.6)
rack (~> 1.3.0)
rack-cache (~> 1.0.1)
rack-mount (~> 0.8.1)
rack-test (~> 0.6.0)
sprockets (~> 2.0.0.beta.10)
tzinfo (~> 0.3.27)
activemodel (3.1.0.rc4)
activesupport (= 3.1.0.rc4)
bcrypt-ruby (~> 2.1.4)
rack (~> 1.3.2)
rack-cache (~> 1.0.3)
rack-mount (~> 0.8.2)
rack-test (~> 0.6.1)
sprockets (~> 2.0.0)
activemodel (3.1.0)
activesupport (= 3.1.0)
bcrypt-ruby (~> 3.0.0)
builder (~> 3.0.0)
i18n (~> 0.6)
activerecord (3.1.0.rc4)
activemodel (= 3.1.0.rc4)
activesupport (= 3.1.0.rc4)
arel (~> 2.1.1)
tzinfo (~> 0.3.27)
activeresource (3.1.0.rc4)
activemodel (= 3.1.0.rc4)
activesupport (= 3.1.0.rc4)
activesupport (3.1.0.rc4)
activerecord (3.1.0)
activemodel (= 3.1.0)
activesupport (= 3.1.0)
arel (~> 2.2.1)
tzinfo (~> 0.3.29)
activeresource (3.1.0)
activemodel (= 3.1.0)
activesupport (= 3.1.0)
activesupport (3.1.0)
multi_json (~> 1.0)
arel (2.1.1)
bcrypt-ruby (2.1.4)
arel (2.2.1)
bcrypt-ruby (3.0.0)
builder (3.0.0)
coffee-rails (3.1.0)
coffee-script (>= 2.2.0)
railties (~> 3.1.0.rc1)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.1.1)
coffee-script-source (1.1.2)
erubis (2.7.0)
execjs (1.1.3)
execjs (1.2.4)
multi_json (~> 1.0)
hike (1.1.0)
hike (1.2.1)
i18n (0.6.0)
jquery-rails (1.0.11)
jquery-rails (1.0.13)
railties (~> 3.0)
thor (~> 0.14)
json (1.5.2)
json (1.5.4)
mail (2.3.0)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.16)
multi_json (1.0.3)
polyglot (0.3.1)
rack (1.3.0)
rack-cache (1.0.2)
polyglot (0.3.2)
rack (1.3.2)
rack-cache (1.0.3)
rack (>= 0.4)
rack-mount (0.8.1)
rack-mount (0.8.3)
rack (>= 1.0.0)
rack-ssl (1.3.2)
rack
rack-test (0.6.0)
rack-test (0.6.1)
rack (>= 1.0)
rails (3.1.0.rc4)
actionmailer (= 3.1.0.rc4)
actionpack (= 3.1.0.rc4)
activerecord (= 3.1.0.rc4)
activeresource (= 3.1.0.rc4)
activesupport (= 3.1.0.rc4)
rails (3.1.0)
actionmailer (= 3.1.0)
actionpack (= 3.1.0)
activerecord (= 3.1.0)
activeresource (= 3.1.0)
activesupport (= 3.1.0)
bundler (~> 1.0)
railties (= 3.1.0.rc4)
railties (3.1.0.rc4)
actionpack (= 3.1.0.rc4)
activesupport (= 3.1.0.rc4)
railties (= 3.1.0)
railties (3.1.0)
actionpack (= 3.1.0)
activesupport (= 3.1.0)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.6)
rake (0.9.2)
rdoc (3.6.1)
sass (3.1.2)
sass-rails (3.1.0.rc.2)
actionpack (~> 3.1.0.rc1)
railties (~> 3.1.0.rc1)
sass (>= 3.1.2)
sprockets (>= 2.0.0.beta.9)
sprockets (2.0.0.beta.10)
hike (~> 1.0)
rdoc (3.9.4)
sass (3.1.7)
sass-rails (3.1.0)
actionpack (~> 3.1.0)
railties (~> 3.1.0)
sass (>= 3.1.4)
sprockets (2.0.0)
hike (~> 1.2)
rack (~> 1.0)
tilt (!= 1.3.0, ~> 1.1)
sqlite3 (1.3.3)
sqlite3 (1.3.4)
thor (0.14.6)
tilt (1.3.2)
treetop (1.4.9)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.28)
uglifier (0.5.4)
tzinfo (0.3.29)
uglifier (1.0.3)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)

PLATFORMS
ruby

DEPENDENCIES
coffee-script
coffee-rails (~> 3.1.0)
jquery-rails
json
rails (= 3.1.0.rc4)
sass-rails (~> 3.1.0.rc)
rails (= 3.1.0)
sass-rails (~> 3.1.0)
sqlite3
uglifier
3 changes: 0 additions & 3 deletions examples/rails/myapp/app/assets/javascripts/home.js.coffee

This file was deleted.

3 changes: 0 additions & 3 deletions examples/rails/myapp/app/assets/javascripts/posts.js.coffee

This file was deleted.

12 changes: 9 additions & 3 deletions examples/rails/myapp/config/application.rb
Expand Up @@ -2,9 +2,12 @@

require 'rails/all'

# If you have a Gemfile, require the gems listed there, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env) if defined?(Bundler)
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require *Rails.groups(:assets => %w(development test))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
end

module Myapp
class Application < Rails::Application
Expand Down Expand Up @@ -38,5 +41,8 @@ class Application < Rails::Application

# Enable the asset pipeline
config.assets.enabled = true

# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'
end
end
3 changes: 3 additions & 0 deletions examples/rails/myapp/config/environments/development.rb
Expand Up @@ -24,4 +24,7 @@

# Do not compress assets
config.assets.compress = false

# Expands the lines which load the assets
config.assets.debug = true
end
14 changes: 10 additions & 4 deletions examples/rails/myapp/config/environments/production.rb
Expand Up @@ -14,12 +14,18 @@
# Compress JavaScripts and CSS
config.assets.compress = true

# Specify the default JavaScript compressor
config.assets.js_compressor = :uglifier
# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = false

# Generate digests for assets URLs
config.assets.digest = true

# Defaults to Rails.root.join("public/assets")
# config.assets.manifest = YOUR_PATH

# Specifies the header that your server uses for sending files
# (comment out if your front-end server doesn't support this)
config.action_dispatch.x_sendfile_header = "X-Sendfile" # Use 'X-Accel-Redirect' for nginx
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx

# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
Expand Down
3 changes: 3 additions & 0 deletions examples/rails/myapp/config/environments/test.rb
Expand Up @@ -36,4 +36,7 @@

# Print deprecation notices to the stderr
config.active_support.deprecation = :stderr

# Allow pass debug_assets=true as a query parameter to load pages with unpackaged assets
config.assets.allow_debugging = true
end
2 changes: 1 addition & 1 deletion examples/rails/myapp/config/initializers/secret_token.rb
Expand Up @@ -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.
Myapp::Application.config.secret_token = 'aeafeef93adc31bfaf5e7cea7e0e73384d84aab370cc18853ea14ef24e882e032a4636aa2ea2047926fa4f7a08308333be3e8cc6348405caf13172d4879c215c'
Myapp::Application.config.secret_token = 'f838e60b8ef13065a9f9bd14fa29bb0818f4d88b88877e54680ccd922ffbd76fc4fe64b8324acda9ccc61d82e1484c37c987d15567531d031b52a1fdf4e0081c'

0 comments on commit 89c08d1

Please sign in to comment.