Fix for the error: PG::UniqueViolation: ERROR: duplicate key value violates unique constraint 'users_pkey' DETAIL: Key (id)=(43957) already exists
#ruby on rails - Page 2 of 3
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 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.
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.
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 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.
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.
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.
In this part, we will learn about how we can insert and update records to the external mysql server using mysql2 gem. We will add two new methods to our service that can insert and update records to mysql server using mysql2 gem.
Database interaction is very simple in rails with Active Record but what if you have to communicate with external mysql server? Gotcha! Let's create a service to perform queries we want without using Active Record.