Juggernaut & Rails
Juggernaut https://github.com/maccman/juggernaut
安装配置
1. nodejs http://nodejs.org
获取 0.4.11稳定版
以下: sudo
wget http://nodejs.org/dist/node-v0.4.11.tar.gz
>tar zxvf node-v0.4.11.tar.gz
>cd node-v0.4.11
>./configure
>make
>make install
2. npm(需NODEJS 0.4以上版本)
以下: sudo
curl http://npmjs.org/install.sh | sh
安装模块
>npm install socket.io
>npm install redis
>npm install optimist
>npm install node-static-maccman
3. 安装并启动redis-server
>redis-server /etc/redis/redis.conf
4. 启动 juggernaut
>git clone https://github.com/maccman/juggernaut.git
>cd juggernaut
>node server.js
4. 创建RAILS应用
>rails new juggernaut_demo
>cd juggernaut_demo
vim Gemfile:
gem 'juggernaut'
>bundle install
>rails g controller welcome index publish
vim routes.rb
root :to => "welcome#index"
get "welcome#publish"
vim application.html.erb
<script src="http://localhost:8080/application.js" type="text/javascript" charset="utf-8"></script>
vim welcome#index.html.erb
<script type="text/javascript" charset="utf-8"> var jug = new Juggernaut; jug.subscribe("demo_channel", function(data){ alert(data); }); </script>
vim welcome_controller#publish
def publish
Juggernaut.publish "demo_channel", "juggernaut demo msg"
end
>rails s
访问: http://localhost:3000/
http://localhost:3000/welcome/publish
Ok,结束。
Posted in Ruby & Rails | 1 Comments | 500 views
HelenaPetty (Feb 17th 2012 at 08:26 PM)
There is not another easy way to receive excellent mark than to compose the term papers and it is, also, available to order the wars essays paper from the essay papers writing service.