Skip to content

Rails 3 Beta

2010 February 11
by suprie

Rails 3.0 beta sudah rilis… baca panduannya di sini

Setelah saya baca dan coba install, ada masalah sedikit. Rack mount yang diinstall adalah versi yang terakhir (0.5.0) sedangkan dependency meminta kita memakai versi =~ 0.4.x. Workaroundnya adalah install yang versi 0.4.0

sudo gem install rack-mount --version=0.4.0

Setelah itu, mari kita coba generate project baru

rails depot3 -d mysql

Seperti halnya rails versi sebelumnya, struktur project dan file-file nya langsung digenerate oleh rails… hampir sama strukturnya, hanya saja sekarang semua yang berada di folder app akan diload secara otomatis, sehingga jika kita membuat obvserver/model.rb maka file itu akan terload otomatis tanpa harus mengotak ngatik konfigurasi lagi.

konfigurasi Rails 3 sekarang pun per aplikasi, jadi environment.rb hanya file untuk meload dan menginitialize, semua konfigurasi per aplikasi sekarang ada di config/application.rb

isi dari file config/environment.rb

# Load the rails application
require File.expand_path('../application', __FILE__)

# Initialize the rails application
Depot3::Application.initialize!

Sedangkan isi dari config/application.rb

require File.expand_path('../boot', __FILE__)

require 'rails/all'

# Auto-require default libraries and those for the current Rails environment.
Bundler.require :default, Rails.env

module Depot3
  class Application < Rails::Application
    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration should go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded.

    # Add additional load paths for your own custom dirs
    # config.load_paths += %W( #{config.root}/extras )

    # Only load the plugins named here, in the order given (default is alphabetical).
    # :all can be used as a placeholder for all plugins not explicitly named
    # config.plugins = [ :exception_notification, :ssl_requirement, :all ]

    # Activate observers that should always be running
    # config.active_record.observers = :cacher, :garbage_collector, :forum_observer

    # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
    # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
    # config.time_zone = 'Central Time (US & Canada)'

    # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
    # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
    # config.i18n.default_locale = :de

    # Configure generators values. Many other options are available, be sure to check the documentation.
    # config.generators do |g|
    #   g.orm             :active_record
    #   g.template_engine :erb
    #   g.test_framework  :test_unit, :fixture => true
    # end

    # Configure sensitive parameters which will be filtered from the log file.
    config.filter_parameters << :password
  end
end

Selain application.rb dan environment.rb, Routing nya pun sedikit berbeda..

Depot3::Application.routes.draw do |map|
  # The priority is based upon order of creation:
  # first created -> highest priority.

  # Sample of regular route:
  #   match 'products/:id' => 'catalog#view'
  # Keep in mind you can assign values other than :controller and :action

  # Sample of named route:
  #   match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
  # This route can be invoked with purchase_url(:id => product.id)

  # Sample resource route (maps HTTP verbs to controller actions automatically):
  #   resources :products

  # Sample resource route with options:
  #   resources :products do
  #     member do
  #       get :short
  #       post :toggle
  #     end
  #
  #     collection do
  #       get :sold
  #     end
  #   end

  # Sample resource route with sub-resources:
  #   resources :products do
  #     resources :comments, :sales
  #     resource :seller
  #   end

  # Sample resource route with more complex sub-resources
  #   resources :products do
  #     resources :comments
  #     resources :sales do
  #       get :recent, :on => :collection
  #     end
  #   end

  # Sample resource route within a namespace:
  #   namespace :admin do
  #     # Directs /admin/products/* to Admin::ProductsController
  #     # (app/controllers/admin/products_controller.rb)
  #     resources :products
  #   end

  # You can have the root of your site routed with "root"
  # just remember to delete public/index.html.
  # root :to => "welcome#index"

  # See how all your routes lay out with "rake routes"

  # This is a legacy wild controller route that's not recommended for RESTful applications.
  # Note: This route will make all actions in every controller accessible via GET requests.
  # match ':controller(/:action(/:id(.:format)))'
end

itu saya copy mentah mentah dari filenya langsung... segini dulu, besok saya coba oprek lagi

One Response leave one →
  1. February 12, 2010

    BAgooessss lo suruh gw baca bahasa dewa ckckckck … jadi inget waktu masih kuliah
    My recent post #3idiots: Mau Sukses? Ikuti Passionmu dong!

Leave a Reply

Note: You can use basic XHTML in your comments. Your email address will never be published.

Subscribe to this comment feed via RSS