Developers can easily define a decorator instead of calling helpers procedurally with models. Developers usually face library integration issues or difficulties in binding the gems while generating the code.
In order to eliminate these issues and debug the errors, PRY turns out to be an ideal choice. SPEC RAILS is a perfect choice for the developers, who are into writing the unit test cases.
This gem facilitates application developers with the integration of Spec framework into any of the Rails projects. Users simply have to generate the required spec helpers and configuration files.
In simple words, SPEC RAILS features descriptive and neat syntax. It a YAML and an ENV file for secure configuration of the applications that are created using Rails.
This gem introduces a convention, which is potential enough to keep the configuration data and SCM separate from each other. DEVISE includes 10 modules, namely- Omniauthable, Database Authenticate, Registrable, Conformable, Trackable, Recoverable, Lockable, Timeoutable, Rememberable, Friendly, and Validate.
The resource URLs are easily identified by the primary key (database ID) of each module. The best part is that it doesn’t require any code modifications in the web application that’s make it a famous Ruby gem.
Paperclip is designed to keep track of the entire process inside the Rails application. The additional benefits offered by this gem include the transformation of images into thumbnails.
It can be extracted directly from Shopify, where multiple tasks are handled by the job table. Some unique features of Delayed Job include Image resizing, sending a huge number of newsletters, updating smart collections, spam checks, HTTP downloads, batch imports, and updating sold after the product changes.
Five million downloads, Laminar tops the list of most popular Rails Gems. This gem offers the ease of setting up the user access restrictions, and all of this can be managed in one place.
The “Authorizations definition library” module of CANCAN CAN allows developers to set the rules for users. Active Admin abstracts the business application patterns and makes it easy for developers to implement elegant and beautiful interfaces with less effort.
Its various features include Scopes, User Authentication, Global Navigation, Action Items, Sidebar Sections, Index Styles, Filters, Downloads, and APIs. Developed especially for Ruby on Rails web applications, Active Merchant can also be integrated as a plugin.
You may find this blog interesting Ruby on Rails: Let’s Bust the Myths, Get Some Facts and Understand Why ROR Is Ideal Choice for Web App Development. They can easily solve the problems related to file testing, uploads, authorization, and authentication.
Using these gems frequently isn’t bad at all, but it is important to use them the right way so that perfect applications are built. Linux and Unix are operating systems that have repositories of software that are installed similarly.
It is excellent that communities such as Ruby and Python wrote package management tools for their languages. In comparison to other alternatives available, one of the best perks that comes with Devise Token Auth is the very little effort you have to invest to get things up and running.
On top of that, you can also customize the different flows mentioned if you want to offer a different experience, and while this may be a little more challenging, it’s not rocket science! I guess authorizing every request on an API can be achieved in the controller, but that is not scalable at all and may ease the introduction of vulnerabilities in an application.
Despite the fact it can have a steep learning curve, specially at the beginning, due to its DSL, once you get used to it, you can have admin pages with CRUD actions for any resource in no time. Also, another strong feature is that you can configure the index filters according to your needs, and they can be customized to use more than one attribute since they support Ransack.
If you need a custom page, you can have Active Admin render your own partial, and you will probably need to make changes in the controller actions. For some people, one of the downsides could be the design, since Active Admin does not come with a powerful CSS framework out of the box.
This is because it easily integrates with Rails, has minimal dependencies, resulting in a fast setup, and it offers a very stable and reliable processing. If your application scales, you will need a framework which delivers performance and in that case I would recommend switching to Sidekick.
By running in memory with Redis, fetching and saving data is much faster than completely relying on the database like Delayed Job, and what’s more, you can have a dashboard to monitor the status of the processes. That’s why the Bootstrap team developed ActiveStorageBase64, which offers an easy way to support uploading base64 encoded files.
The main reason for this is that it encourages human-readable tests, which ends up helping a lot in the development process. Last but not least, if your API relies on third party services you will need stubbing on the external HTTP requests and for this I recommend using Web mock.
:). The idea is that after doing the tutorial you will be able to create a complete administrative system (with authentication) for any type of business :). As an example we will create a system to manage the rental of vehicles where you can register the car fleet, the customers, the rents and also record possible “claims” that have occurred during the car rental.
Each feedback I received in the first two posts are greatly serving as incentive for me to continue to produce valuable content and further improve the quality of the work. Simply, thank you all! PROJECT INGREDIENTSTUTORIAL GOALS Create our Rails 5 Project and install the Gem of Rails Admin.
* NOTE: If you are using Rails 4, you do not need to add the first Gem (remotipart). When you run the command, Rails Admin will ask on which route you would like to install, in this tutorial I will leave / admin as the default, but you can choose another route or even install in home.
\o/ We are Online:), let’s configure Rails Admin now! DATABASE Just remembering, the example we are doing here today is a simple system to manage the rental of cars.
Client: People who will rent the cars. Claim: If an accident occurs during the rental of a car, this table stores what happened.
To finalize add the following line in the model “Claim ”. Access the browserhttp://localhost:3000/admin and see how your administrative site is now with the new tables.
\o/ Great, we can now create, edit, or delete data in our tables. Play around with your administrative system and learn how to use Rails Admin interface, you will see that it is quite complete.
Now go to the file “config/initializers/ rails_admin .Rb”, there you will be able to edit your management system in the future, but for now look for the following patch of commented code and “uncomment” it : ## == Devise == # config.authenticate_with do # warden. Authenticate! Excellent, now in the browser go to http://localhost:3000/admin, and you will be redirected to the Login screen.
Wonderful, we have our login page (you can customize it, in the Devise documents you can learn how, click here), since you do not have an account yet, you can click “Sign Up” and create your account to login. \o/ Great, we managed to create an authentication method using Devise.
To end this tutorial in great style, we will now put a theme in our Rails Admin to make it more presentable. BUT FIRST A SIMPLE TASK FOR YOU TO PROBE You may have noticed that where we put relations between the models (has_one), we ended up with two visible fields, for example, in this picture below the creation of Rental, we have twice the car field and twice the customer field.
You can make it appear only once by adding to the file “config/initializers/ rails_admin .Rb” which model field you would like to appear. INSTALLING THE TEMPLATE We already have our ready and functional website, but of course, adding new features to it is in your hands (but if you need advice, just talk to me on Facebook).
Now just run Rails and see how your admin looks beautiful CONCLUSION AND INDICATIONS Thanks for following this tutorial until here \o/, I hope it helps you to create administrative systems in a simple manner using Ruby on Rails + Rails Admin.
Rails Admin is pretty cool and has more options that can be explored, to find out more take a look at their Wiki in this link. I’ve done an inventory management system for Trust Films using Rails Admin and the result was amazing, so you can do cool stuff with this Gem.
If you want to access the complete code of what we did here for reference, please visit GitHub clicking here. I’m working hard to create quality content and in Portuguese, so if you liked this tutorial and others, share it with your friends :), it helps a lot (there are some share buttons below).
If you have any questions, write in the comments or talk to me on Facebook. If you have not signed up, sign up to our Newsletter here on the right side and on top, every Friday I send a summary of the best that I produced in the week for you.