#ruby on rails - Page 2 of 3

Update Multiple Records at Once in Rails

Published by Prabin Poudel 3 min read
cover: Update Multiple Records at Once in Rails
We can update static values of existing records with the method update_all. But what if we want to update records with different value for different attributes? In this blog, we will be looking at the solution on updating multiple records at once in Rails when each record can have different attribute and value.

Override Default Date Format in Rails Admin

Published by Prabin Poudel 2 min read
cover: Override Default Date Format in Rails Admin
It's always tricky when we need to override default behavior of engine/gems. It was the same case with date format. Rails Admin uses long date format as a default value for formatting the dates, to override the format we can add keys for the long date format in our locale files

[Fix] Rails Auto Increment ID Postgres Error

Published by Prabin Poudel 1 min read
cover: [Fix] Rails Auto Increment ID Postgres Error
Fix for the error: PG::UniqueViolation: ERROR: duplicate key value violates unique constraint 'users_pkey' DETAIL: Key (id)=(43957) already exists

[Fix] Rails server is already running

Published by Prabin Poudel 2 min read
cover: [Fix] Rails server is already running
A server is already running. Check .../tmp/pids/server.pid This error means the rails server suspended or stopped abruptly, due to which background process is already running on the port that rails server was previously running on.

Live Stream Logs to Browser with Rails

Published by Prabin Poudel 11 min read
cover: Live Stream Logs to Browser with Rails
Live streaming files content to browser in Rails can be accomplished with the use of Server Side Events. In this tutorial, we will be learning to live stream content inside log files to the browser from Rails controller by using file watcher and server side events.

Setup Factory Bot in Rails

Published by Prabin Poudel 2 min read
cover: Setup Factory Bot in Rails
Factory Bot is a ruby library for setting up test data objects in Ruby. Today we will be setting up Factory Bot in Rails which uses RSpec for testing. Factory Bot helps developers to write less code while testing with the factory objects that is created for each model.

Integrate Pronto with Gitlab CI for Rails App

Published by Prabin Poudel 7 min read
cover: Integrate Pronto with Gitlab CI for Rails App
There are multiple ways to fix missing top level class documentation comment in Rubocop. You can disable it in your whole app with by disabling cop in the whole project, disable it in one class or just add a comment above the class declaration.

Rubocop Configuration Files for Rails

Published by Prabin Poudel 5 min read
cover: Rubocop Configuration Files for Rails
Rubocop is a linter for Rails. Rubocop helps in enforcing best practices for Ruby and Rails. It helps in maintaining consistency throughout the project. It also has option for autoformatting the code based on the configurations.

Interact with Mysql Server using mysql2 gem [Part 4] - Perform Transactions

Published by Prabin Poudel 13 min read
cover: Interact with Mysql Server using mysql2 gem [Part 4] - Perform Transactions
In this part, we will learn about how we can perform transactions in the external mysql database using mysql2 gem. Transactions helps us in making multiple queries to database ensuring all queries are performed or none at all.

Interact with Mysql Server using mysql2 gem [Part 3] - Prepared Statement

Published by Prabin Poudel 7 min read
cover: Interact with Mysql Server using mysql2 gem [Part 3] - Prepared Statement
In this part, we will learn about how we can perform prepared statements to the external mysql database using mysql2 gem. Prepared statements are very useful against SQL injections.