Rails
From Rory.wiki
Contents |
General
Notes
rake routes shows the routes that are set-up for a given application
in routes.rb map.resources :model sets up the standard RESTful routes for a model.
in views
<% @models.each do |model| -%> <%= link_to "Link text", model_path(model) %> <% end -%>
will set up links to the model object
in views
<%= debug @object %>
Changing the default IP address and Port
In rails3 if you want to change the default IP address and port that a rails app runs (without external scripts or changing the rails source) then you need to alter the script/rails file.
The following was derived from this post and this change to dradis and just sets the default IP address for the app. to be 127.0.0.1 and the default port to be 3000.
require 'rubygems' require 'rails/commands/server' require 'rack' require 'webrick' module Rails class Server < ::Rack::Server def default_options super.merge({ :Port => 3003, :Host => "127.0.0.1", :environment => (ENV['RAILS_ENV'] || "development").dup, :daemonize => false, :debugger => false, :pid => File.expand_path("tmp/pids/server.pid"), :config => File.expand_path("config.ru") }) end end end
Links & Resources
Rails Guides Getting Started
Rails 2.3 tutorial Rails with one Model
Rails 2.3 tutorial Rails with multiple models
