简体   繁体   English

Ruby on Rails中的最后20%

[英]The last 20% in Ruby on Rails

I am (quite) an experienced programmer but totally new to Ruby and Ruby on Rails. 我(非常)是一位经验丰富的程序员,但对Ruby和Ruby on Rails来说却是全新的。

RoR looks great to get working quickly, specially the automatic screen generation for CRUD operations. RoR看起来非常适合快速工作,特别是CRUD操作的自动屏幕生成。

It really it gets you productive quickly. 它确实可以让您快速提高工作效率。

The questions is with the last 20% of the work, when I must finish my application. 当我必须完成我的申请时,问题是最后20%的工作。 Won't RoR conventions stand in my way? RoR会议不会妨碍我吗? Because not every database table must be available for all users, and not all users can edit all columns and/or all rows, and the views must be adapted to my site's look and feel, etc. 因为并非所有用户都可以使用每个数据库表,并且并非所有用户都可以编辑所有列和/或所有行,并且视图必须适应我的站点的外观和感觉等。

I understand RoR has been used successfully in live sites, but how exactly do you gain enough speed in RoR to escape gravity after the first phase has been burned out. 我知道RoR已成功应用于现场,但是在第一阶段烧毁后,你在RoR中获得足够的速度以逃避重力的方式。

I don't think scaffolding gets you 80% there. 我认为脚手架不会让你80%。 Scaffolding is nice in that it shows you how the pieces of Rails fit together, but I wouldn't build my application off of scaffolding code. 脚手架很好,因为它向您展示了Rails的各个部分是如何组合在一起的,但我不会使用脚手架代码构建我的应用程序。 Now that you've been impressed by scaffolding it's best that you forget all about it. 现在您对脚手架印象深刻,最好忘记它的全部内容。 :) :)

Where Rails really shines in my mind is database migrations , the awesomeness of how dynamic ActiveRecord is, and the plugin ecosystem. Rails在我脑海中真正闪耀的地方是数据库迁移 ,动态ActiveRecord的真实性以及插件生态系统。

There's a lot to learn when deciding to go with Rails. 决定使用Rails时需要学习很多东西。 You have a new language, new framework, and new plugins - but if you take the time to learn those things you can be very productive with Rails. 你有一个新的语言,新的框架和新的插件 - 但如果你花时间学习这些东西,你可以使用Rails非常高效。

I've been doing ruby on rails for quite sometime. 我一直在铁轨上做红宝石很长一段时间。 The 80/20 problem is not unique for rails. 80/20问题并非铁路独有。 It applies generally to the entire world. 它通常适用于整个世界。 I'm also not aware of any framework that can just do business logic for you. 我也不知道任何可以为你做业务逻辑的框架。

To answer your specific questions. 回答你的具体问题。 Conventions will not stand in your way while doing the 20%. 在做20%时,约定不会妨碍你。 Instead, conventions will help you to get through that 20% quicker. 相反,惯例将帮助您更快地完成20%的速度。

Personally, for user authentication, I use Authlogic. 就个人而言,对于用户身份验证,我使用Authlogic。 For user authorization, I use Lockdown or Authorization plugin depending on customer need. 对于用户授权,我根据客户需要使用Lockdown或Authorization插件。

I also use inherited_resource in most of my projects to simplify controller code. 我还在大多数项目中使用inherited_resource来简化控制器代码。 This is another power of convention. 这是惯例的另一种力量。

To increase speed of development, you will not only need to know Rails, but rails gems/plugins that does the right things for you, so you don't have to reinvent the wheels again. 为了提高开发速度,您不仅需要了解Rails,还需要为您提供正确的东西,因此您无需再次重新发明轮子。 Also, knowing Ruby language is a must for quickly develop beyond the 80%. 此外,了解Ruby语言是快速发展超过80%的必要条件。

Ruby Toolbox provides some of the most popular gems and plugins used in typical rails projects targeted at specific domains. Ruby Toolbox提供了针对特定域的典型rails项目中使用的一些最流行的gem和插件。 You can look through the relevant categories and know what most people use. 您可以查看相关类别并了解大多数人使用的内容。 (And it's probably a good idea to use popular, well maintained gems) (使用流行的,维护良好的宝石可能是一个好主意)

TDD/BDD style development will also help you to speed up in the long run. TDD / BDD风格的开发也将帮助您从长远来看加速。

Lastly, a warning: If you stray away from rails convention, you will have a painful time in general. 最后,一个警告:如果你偏离轨道惯例,你将会有一个痛苦的时间。

PS I used Merb before. PS我以前用过Merb。 My feeling is that conventions helps you in merb, but you won't get too much penalty for not following them in merb. 我的感觉是惯例可以帮助你使用merb,但是你不会因为没有在merb中使用它们而受到太多的惩罚。 However, my experience with Rails is that if you decide not to follow rails convention while developing rails app, it will come back to bite you in one way or another! 但是,我对Rails的体验是,如果你在开发rails应用程序时决定不遵循rails约定,它会以某种方式回过头来咬你! So think twice when you really attempted to stray away from rails conventions... (This is from my own experience, and of course subjective, but you can think of it as a warning...) 所以当你真的试图偏离铁路惯例时要三思而后行......(这是我自己的经验,当然是主观的,但你可以把它当作警告......)

Won't RoR conventions stand in my way? RoR会议不会妨碍我吗? Because not every database table must be available for all users, and not all users can edit all columns and/or all rows, and the views must be adapted to my site's look and feel, etc. 因为并非所有用户都可以使用每个数据库表,并且并非所有用户都可以编辑所有列和/或所有行,并且视图必须适应我的站点的外观和感觉等。

This is a bit of a non-sequitur. 这有点不合理。 Rails is a framework that has been lifted from real world applications. Rails是一个从现实世界的应用程序中解脱出来的框架。 Those applications had to deal with all those issues also, as well as others you may not have thought of yet. 这些应用程序也必须处理所有这些问题,以及您可能还没有想到的其他问题。 Generally, the conventions make life easier once you learn them. 一般来说,一旦你学会了这些惯例,生活就会变得更容

Another point is that the conventions are merely conventions. 另一点是,这些惯例仅仅是惯例。 You don't have to follow them. 你不必遵循它们。 You do not even have to use RoR for everything, though I've yet to find a case where I didn't/couldn't, I do generally try to push as much into the DB or cache layers as possible. 你甚至不需要为所有东西使用RoR,虽然我还没有找到我没有/不可能的情况,我通常会尽可能多地尝试进入DB或缓存层。

I don't believe that you'll ever have a serious problem with Rails conventions. 我不相信你会遇到Rails惯例的严重问题。 Just stick with the conventions and trust the RoR system. 坚持惯例并信任RoR系统。 The people behind Rails put a lot of effort into these conventions to support 99% of the common usage scenarios. Rails背后的人们为这些约定投入了大量精力来支持99%的常见使用场景。

If you really need to do something outside the conventions it will eventually get complicated quite fast. 如果你真的需要在约定之外做一些事情,它最终会很快变得复杂。 However, you are not alone. 但是,你并不孤单。 There are a lots of excellent resources on the net to get help (for example the StackOverflow community). 网上有很多优秀的资源可以获得帮助(例如StackOverflow社区)。

To sum it up: 把它们加起来:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM