Debugging represents one of the most important activities in software development that you need to do on a regular basis. As a developer, you spend time trying to build something, or change something that is already implemented.
Continue readingTag: gem (Page 1 of 2)
Globalize is one of the most famous gems that is used for translating dynamic content in Rails application. It is really easy to use, and brings a lot of conveniences immediately after you add it in your application. I recently had to do a more complex query using the table added by Globalize generator, and I could not find that much information about ways of doing joins for this newly added table with the one that it corresponds and that translates its attributes. In this article, you can see a short example on how to do that.
We are in an interconnected world, where people across the planet can use the projects that we develop, and having the opportunity to offer them with additional international languages make them a lot better. We can obviously use locale for doing the translations of static strings like labels, or placeholder descriptions that appear across our applications, so we should also have something that can give us a way to translate the dynamic content. There is a really great Ruby gem that makes the translation of model attributes a lot easier. This gem is called Globalize and is very easy to use.
I recently had an issue with Rails Admin, which was displaying duplicate models in the left hand side menu. It was something that I had not encountered before, and it turned out, it was a rare occasion, as I could not find that much coverage about it. I also saw that this unanswered question related to this problem was published more than a year and a half ago in StackOverflow. This is the reason why I decided to write this post. Continue reading
It is highly likely that you will have to work on a project that has some type of search forms implemented. Fortunately, as with many other type of functionalities that you can easily get out of the box without writing too much code in Rails projects, there is also a gem that is specific for this purpose. Ransack is a Ruby gem that enables the creation of both simple and advanced search forms for Ruby on Rails projects.
It is no doubt that one of the activities that takes most of the time of software developers is debugging. We as programmers can make many mistakes, which may lead to many bugs that need to be fixed. One of the best ways to fix these bugs, understand the flow of an application, or implement new features is through debugging. ByeBug is a great Ruby gem that helps us fix bugs and debug projects by going through each line. It is similar to pry, with additional functionalities.
It’s obvious that a lot of applications need an admin panel, where the administrator or other lower level users need privileges to do certain data manipulations. Not everyone of them should be a technical person. Thus, you may need to provide them a user-friendly interface which gives them this opportunity. Fortunately, you can insert an admin panel in your Rails application easily using RailsAdmin.
It is no doubt that there are certain pages that you do not need to have them viewed by all the visitors of your application. You can also have users of different roles that may not be allowed to access certain parts of your applications. There is a really good Ruby gem called cancan that excels at this. It makes the authorization of your app resources pretty straight-forward, so you do not have to duplicate permission checking code across controllers and views.
Rails controllers have callbacks that can be useful when we want to execute a particular piece of code before or after other methods have been invoked. However, there is no Rails built-in after_response_sent callback that could be used to invoke a method after we have rendered the response to the user, either via an HTML or JSON response. Continue reading