RubyTuesday [上海][2012年03月27日] Ruby Tuesday 活动公告

lgn21st · 2012年03月26日 · 最后由 fentick 回复于 2012年03月28日 · 3959 次阅读

上海 RubyTuesday 活动召集!

主题:介绍 Rails Engine 报名:不需要 费用:咖啡店请自行点单 欢迎上海的 Rubyist 参加!

Rails::Engine allows you to wrap a specific Rails application or subset of functionality and share it with other applications. Since Rails 3.0, every Rails::Application is just an engine, which allows for simple feature and application sharing.






时间:2012 年 03 月 27 日(周二)晚上 6:30 至 9 点 地点:浦东新区世纪大道 8 号上海国金中心 D 座 B1 楼 LG1-37 室,COSTA COFFEE(国金中心店) 交通:位置在浦东陆家嘴的 Apple Store 旁边,提早到达的同学请负责占座 ^_^ 网址:http://www.dianping.com/shop/4600640

要去的,Daniel 那有干货!

这次我应该能来

是不是在上海的谁都可以去参加?

这次一定要来的。

南京 有去的么 搭个伴啊 俺路痴

engine 是好东西

#5 楼 @jhjguxin 下个月可以同去啊,这个月就没空了

唉,想去啊。。

@ShiningRay 一定哦 另外 还有没有 南京要去的啊 一路嘛

@lgn21st 非常实用的话题,一定参加。当你的应用功能越来越多,代码规模越来越庞大的时候,合适的方式组织应用会变得非常重要,Rails::Engine 是其中一种很棒的解决方案,期待 Ruby Tuesday!

我们项目也正在用 Rails::Engine,一定去

#9 楼 @jhjguxin 周二不用上班?

@zhiliang 上班啊 谁周二不上班啊 请假呗 有一路的么

#14 楼 @jhjguxin 天哪,你来回 600 多公里,为了是来上海参加一个 2 小时的活动,这个太夸张了啊!这样过来成本太高了!

#15 楼 @lgn21st 静候 slides 流出..

#17 楼 @jhjguxin 在南京自行组织,也不一定谈 ruby,想到什么聊什么

哈,@lgn21st 我们去 4 个人。

#18 楼 @nouse #17 楼 @jhjguxin 对的,在南京自己组织呀。

汗 南京的的大大们 有当地的么 我 是人生地不熟的 南京组织 俺一定到

#21 楼 @jhjguxin 自己组织呀,你就在市区中心,交通便利的地方比如新街口找个咖啡吧,然后发个帖子,AT 一下坛子里面各位南京的大大们就好了啊。 http://ruby-china.org/users/location/%E5%8D%97%E4%BA%AC

我觉得 可以每次做讲座的视频和 slide 都弄下来做一个聚合,这样去不了的也能看到了。

可以录像不……考虑带 DV :-P

#24 楼 @fentick 真不用带,现场环境和气氛不是 training,而是讨论交流,这个给我太大压力了,呵呵。

@lgn21st Hello,我报名参加,从七宝过去,大概 7 点多到-__-,接头暗号是啥?

刚刚一个朋友跟我说,看到 Engine 就想到了 Engine Yard,我想想也是哦,在 Rails 3 以前,一看到 Engine,就想要一个词“丫的!”

签到,哈哈

今天给大家分享的内容:

Rails Engine

Before Rails 3

What is Rails engine

A Rails Engine is a method for embedding one Rails applicaiton into another. Engines have been available as a plugin around for years, but it is now built in to Rails 2.3. RailsCasts: Rails Engine

DHH 关于 Rails Engine 的吐槽 The case against high-level components

All attempts at creating high-level business components that can be re-used and re-configured have failed previously. This failure has not been for technical reasons - it happens because the requirements that yielded the original component interface were sufficiently different from the new requirements so as to require re-writing massive chunks of functionality.

Engines 的作者对 DHH 的吐槽的吐槽

Engines fill a fairly specific need that we (my team) have, which is the development of multiple distinct Rails applications which share common components (authentication, reporting, importing data from hellish Excel), and ensuring that a means to apply patches & bug fixes across each of these applications, including models, controllers and views with the minimum of developer time spend on managing those updates. Need to roll-back to a previous version of the Reporting system? Just change the SVN external and everything within the Engine goes back to the way it was. With generators (less so with those that come with plugins, but this still holds true), the code would have to be regenerated back into the /app directory.

……

Engines have not recieved the blessing of the RoR core team, and I wouldn't expect any different, because it would be madness to include them in the core Rails. It's a mechanism far too easily [ab]used for things it's not actually suitable for. I did speak to Jamis (cc'd to DHH) about them quite some time ago, before plugins existed in a released form. Their advice was to reimplement our mechanism as a plugin, and if anything we were doing could not be achieved in this way, they would re-examine their plugin mechanism to see what could be adapted.

As it turns out, we can do everything we need within their plugins architecture, so we have a happy coexistance - Rails stays clean, but is flexibly enough to support our (hopefully not too outlandish) needs. It's not like we're forking the project or taking digging our heels in and taking a stand against anything.

无力的官方吐槽 (作者其实是 DHH):Why engines and components are not evil but distracting

So what am I saying? That engines should be stopped? Of course not. But I am saying that Rails will continue to send a signal with what’s included in the core that this is a sideshow project. It satisfies some needs for some people and that’s great. But the goal of Rails is to create a world where they are neither needed or strongly desired. Obviously, we are not quite there yet.

我关于 Rails Engine 的吐槽

简单的说,如果不用 Subsctuct,节约出来的时间和精力足够我把 Substruct 作的事情推翻重做三遍以上了。

limitations of Engine in Rails 2.3

  • No migration support.
  • No public asset support.
  • Like plugins, naming becomes a concern.

After Rails 3

Rails engines allow our gem to have controllers, models, helpers, views, and routes…

For Rails 2.3, in order to make Engine work, Rails had to hook into Rubygems and check each gem that was loaded.

For Rails 3.x, we needed an explicit way to create engines, allowing it to work in any scenario, not only with Rubygems. Whit that in mind, Rails now ships with a new class Called Rails::Engine.

RailsCasts:

Paths

In Rails 3, a Rails::Engine does not have hard-coded paths. This means we are not required to place our models or controllers in app/.

module MyEngine
  class Engine < Rails::Engine
    paths.app.controllers = "lib/controllers"
  end
end

More info, please check out rails/railties/lib/rails/engine/configuration.rb

Engine Initializer

An engine has several initializers that are responsible for making the engine work.

>> Rails::Engine.initializers.map(&:name)
=> [:set_load_path, :set_autoload_paths, :add_routing_paths, :add_locales, :add_view_paths, :load_environment_config, :append_assets_path, :prepend_helpers_path, :load_config_initializers, :engines_blank_point]

initializer :add_routing_paths do |app|
  paths.config.routes.to_a.each do |route|
    app.routes_reloader.paths.unshift(route) if File.exists?(route)
  end
end

Engine and Rack

What is rack?

The Rack specification clearly outlines the API used by Rack applica- tions to communicate with a web server and between themselves: A Rack application is a Ruby object (not necessarily a class) that responds to call. It takes exactly one argument, the environment, and returns an array of exactly three values: the status, the headers, and the body.

Why rack?

By following the Rack API, a web framework could use Rack web servers adapters instead of providing its own, removing the duplication of effort existing in the Ruby community.

While Rails 2.2 already provided a simple Rack interface, Rails more closely embraced Rack and its API in version 2.3. However, the Rack revolution really happened in Rails 3.

How rack?

Dependency nightmare?

New mountable engines come with fully isolated namespace. which let an e-commerce soltuion like Spree, a Forum like Forem or a CMS like Refinery or Locomotive in you own Rails application.

Create engine

  • Enginex for Rails 3.0
  • rails plugin new for Rails 3.1

DEMO

ignore...

来自薄荷网的@vincent 拟定下次跟大家分享关于 Rails 里面的搜索,全文检索方面的话题。

今天活动的照片,Daniel 又讲了不少,辛苦了

今天第一次参加,受益匪浅,感谢 daniel 的分享!

看上去不错的样子,可惜了,今天不能来。。

哎。。又没去成。。

看样子很不错哦,可惜人不在上海

……现场唯一的代码盲飘过……

需要 登录 后方可回复, 如果你还没有账号请 注册新账号