Rails 2.0 apps without a database
If you are interested in spinning up a Rails app without a database, it is a little trickier in 2.0 than in previous versions. Do the following:
This sets up a basic Rails app with a controller. Modify
You now have a basic controller set up. Let's tell Rails not to use ActiveRecord. We do that by opening up
So far, this is how you'd do this in Rails 1.x. However, in 2.0 they introduced a new file which will also try to use ActiveRecord. So open up the
You should now be able to fire up
rails nodbspike
script/generate controller hello
This sets up a basic Rails app with a controller. Modify
app/controllers/hello_controller.rb to include the following:
def index
render :text => "Hello, world!"
end
You now have a basic controller set up. Let's tell Rails not to use ActiveRecord. We do that by opening up
config/environment.rb and adding the following line:config.frameworks -= [ :active_record ]So far, this is how you'd do this in Rails 1.x. However, in 2.0 they introduced a new file which will also try to use ActiveRecord. So open up the
config/initializers/new_rails_defaults.rb file and comment out the two ActiveRecord lines.You should now be able to fire up
script/server, browse to http://localhost:3000/hello and code away!




0 Comments:
Post a Comment
Links to this post:
Create a Link
<< Home