- Rubymine ruby on rails tutorial how to#
- Rubymine ruby on rails tutorial upgrade#
- Rubymine ruby on rails tutorial code#
However, in the end, it’s not really an important difference. The main reason is that I often want to replace the collaborators with some in-memory fakes during testing and the constructor feels better for it. Q: Do you have some rule which params you pass to constructor of service object, and which to execute/call method?Ī: I put the collaborators to the constructor and other params to the execute/call method. Maybe suggest that your senior team members work on those phases so that they’re not involved in the long-term work ? Rails-way people are great for making the first versions of the product. Senior Rails-way people are probably the hardest to convince to refactoring.
Rubymine ruby on rails tutorial how to#
Q: How to convince other team members to start the refactoring, especially more “senior” ones focused on classic-Rails-apps-way?Ī: Oh, that’s hard.
Rubymine ruby on rails tutorial upgrade#
You just test the business logic and the integrations with other parts (which you can replace with InMemory objects).Īll in all, those patterns make it easier to upgrade Rails, as you can check every small bit if it still works with the new Rails version. In its final state, you can use the service objects together with domain objects and test it all without even loading Rails. The same benefits as above apply: easy to test and easy to verify in case of upgrades. (BTW, in a way, repositories are adapters too.) You can wrap sending email with a NotificationAdapter, even though it’s part of Rails. I use adapters for encapsulating all kind of external world access. This means that after a Rails upgrade you can easily check if db access is still working. Repositories have a well-defined scope and are easy to test. Inside them it’s OK to use ActiveRecord objects/classes. Repositories help you with encapsulating data access. Q: Does this kind of pattern reduce/isolate problems of Rails upgrades?Ī: This webinar was mostly about the service objects, but I also mentioned repositories, adapters, and form objects. It’s also forcing me to decouple the controller state a bit. I don’t really have much experience in using Rails concerns, as I never felt it would be of any help. The reasons I’m using a new class is because it makes it easier to test. I know that I’m against the main rule of DHH’s way, but I really see no point in controller concerns. Q: Is a good idea to move services to a controller concern?Ī: To be honest, no. Unfortunately there wasn’t enough time to answer all of them online, but Andrzej has now kindly answered the rest. We’ve got a lot of interesting questions during the webinar.
Rubymine ruby on rails tutorial code#
Rails refactoring guru Andrzej Krzywda shares his experience and best practices during this session. Andrzej shows how to apply typical refactoring recipes to put your code in order, with examples of service objects and other patterns, all using RubyMine refactorings extended with custom shortcuts: We’ve been asked when the last Tuesday webinar recording would be available, and now you can watch it on YouTube JetBrainsTV channel.