require.config({//声明模块的位置paths:{"jquery":"libs/jquery""login":"libs/login"}//或使用baseUrl指定所有模块的路径baseUrl:"js/libs"});//使用require加载模块,第一个参数为数组,即要加载的模块,将按数组顺序加载;第二个为回调函数,在全部加载完成后执行。require(['jquery','login'],function($,Login){alert("jquery and login module load success!");Login.do_login();//some else});
符合amd的login module定义
1234567891011121314151617
//依赖jquery的定义define(['jquery'],function($){// some definationsfunctiondo_login(){$.post('/sessions/create',{uname:$("#uname").val(),password:$("#password").val()},function(data){//some });return{do_login:do_login};}});//不依赖其他模块的定义define(function(){//some definationsreturn{xx:xx};});
** **rake middleware
use Rack::Sendfile
use ActionDispatch::Static
use Rack::Lock
use #<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x007feef1563b90>use Rack::Runtime
use Rack::MethodOverride
use ActionDispatch::RequestId
use Rails::Rack::Logger
use ActionDispatch::ShowExceptions
use WebConsole::Middleware
use ActionDispatch::DebugExceptions
use ActionDispatch::RemoteIp
use ActionDispatch::Reloader
use ActionDispatch::Callbacks
use ActiveRecord::Migration::CheckPending
use ActiveRecord::ConnectionAdapters::ConnectionManagement
use ActiveRecord::QueryCache
use ActionDispatch::Cookies
use ActionDispatch::Session::CookieStore
use ActionDispatch::Flash
use ActionDispatch::ParamsParser
use Rack::Head
use Rack::ConditionalGet
use Rack::ETag
run Fool::Application.routes
#!/usr/bin/env ruby## This file was generated by Bundle.## The application 'guard' is installed as part of a gem,and this file is here to facilitate(正式) running it#require'pathname'ENV['BUNDLE_GEMFILE']||=File.expand_path("../../Gemfile",Pathname.new(_FILE_).realpath)require'rubygems'require'bundler/setup'loadGem.bin_path('guard','guard')