简体   繁体   English

在不使用任何额外宝石的情况下在铁轨上开发红宝石是不是很奇怪

[英]Is it weird to develop in ruby on rails without using any additional gems

I have always found that a lot of rails developer will usually defer a lot of tasks to gems rather writing code themselves, and sometimes I find myself not using them at all due to the fact that the gems doesn't behave exactly like how I wanted to in some minor way, is this weird to any of you? 我总是发现许​​多rails开发人员通常会将很多任务推迟到gems而不是自己编写代码,有时我发现自己根本没有使用它们,因为gems的行为并不像我想要的那样以某种微小的方式,这对你们任何人来说都很奇怪吗?

Btw, I do use gems that perform cryptographic tasks like bcrypt and mysql2 for database connections but I never find myself using gems like Devise/Authlogic for authentication. 顺便说一句,我确实使用gems执行加密任务,如bcrypt和mysql2进行数据库连接,但我从未发现自己使用像Devise / Authlogic这样的宝石进行身份验证。

You can forget about Rails and ask yourself - "whether I need standard libraries or do I need to create my own?" 您可以忘记Rails并问自己 - “我是否需要标准库或者我是否需要创建自己的库?”

Reuse of existence code is a good practice in the software development. 重用存在代码是软件开发中的一个很好的实践。

It is in the Rails philosophy to use gems to not reinvent the wheel and above all to do more with less. 在Rails哲学中,使用宝石不重新发明轮子,最重要的是用更少的东西做更多的事情。

Good gems should be configurable as you could use it for your needs. 好的宝石应该是可配置的,因为你可以根据自己的需要使用它。

You asked whether it's weird? 你问这是不是很奇怪?

No, it is not. 不它不是。 I often have the same problem to solve. 我经常遇到同样的问题需要解决。 When you use a gem, you often need to adapt it to your needs. 当您使用宝石时,通常需要根据您的需要进行调整。 When you update this gem, you may need to apply your changes again, or you have a problem when the gem starts to act in a different way you want it. 当您更新此gem时,您可能需要再次应用更改,或者当gem开始以您想要的其他方式操作时您遇到问题。

When you create your own solution, you know it well (so, you don't need to deal with other persons' bugs, just with your own ones), the solution always exactly matches your needs and you change it whenever you need. 当您创建自己的解决方案时,您就会很清楚(因此,您不需要处理其他人的错误,只需使用您自己的错误),解决方案始终完全符合您的需求,您可以随时根据需要进行更改。

The examples of gems you use (bcrypt and mysql2) are the good examples of some very general tasks, which do not need any modifications in the lifetime of your application. 您使用的宝石示例(bcrypt和mysql2)是一些非常常见的任务的好例子,它们在您的应用程序的生命周期中不需要任何修改。 You will not need to change the crypto protocols, neither the database connections need application-specific changes. 您不需要更改加密协议,数据库连接也不需要特定于应用程序的更改。

But the authentication system may require adaptations, so it's better to depend on your own, independent solution. 但是身份验证系统可能需要进行调整,因此最好依赖于您自己的独立解决方案。 However, you may want to copy 'their' solutions, without making your project dependent on 'foreign' code. 但是,您可能希望复制“他们的”解决方案,而不会使您的项目依赖于“外部”代码。 The project gnulib takes a similar approach. 项目gnulib采用了类似的方法。

UPDATE: 更新:

See the article http://www.aidanf.net/rails_user_authentication_tutorial . 请参阅文章http://www.aidanf.net/rails_user_authentication_tutorial There you will find a few reasons for writing your own authentication system, explained much better than I tried ;) 在那里你会发现编写自己的身份验证系统的一些原因,解释得比我尝试的要好得多;)

I think I agree with the position to not use plugins/gems every time you want to add a functionality in your rails apps. 我想我同意每次想要在rails应用程序中添加功能时不使用插件/宝石的立场。

I feel like some gems or plugins may behave oddly when there are associated with others gems or plugins. 我觉得当与其他宝石或插件相关联时,某些宝石或插件可能表现得很奇怪。 I think about the act_as_*, authentification systems.. 我想到了act_as_ *,认证系统..

For example, to build your own tag system, which is quite easy, you can study act_as_taggable and try to write your own. 例如,要构建自己的标记系统,这很容易,您可以学习act_as_taggable并尝试编写自己的标记系统。 I think the time spent will be the same than having to learn the plugin. 我认为花费的时间与学习插件的时间相同。

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

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