Skip to main content

All Questions

-2 votes
1 answer
275 views

Trying to connect Ruby on Rails with PostgresSQL

Everytime, I tried to create a user. This is what it shows: sudo -u postgres createuser jenn -s $ psql --version Warning: No existing cluster is suitable as a default target. Please see man ...
JS3's user avatar
  • 1,879
3 votes
0 answers
1k views

Ruby pg-1.4.4 Segmentation fault at 0x0000000000000000

I see Segmentation fault at 0x0000000000000000 error when I try to connect to postgresql. I use ruby 2.7.7, Ubuntu 22.04.1 LTS, rails (5.2.6.2) What is the reason? /home/vital/.rvm/gems/ruby-2.7.7/...
Vital's user avatar
  • 31
-1 votes
1 answer
83 views

OPTIMIZE QUERY ON RAILS - POSTGRESQL

I have 3 scopes: 1 - lists the promotions in progress. 2 - sort out of stock last 3 - list the promotions that are not in progress. Is it possible to combine everything in a single scope? It would be: ...
Roberto da Silva's user avatar
0 votes
0 answers
55 views

How to cast ID field to text in squeel query

I essentially want to perform a LIKE query on a PostgreSQL primary id column for a query generated using Squeel and I don't think Squeel is understanding the syntax I'm giving it. Any ideas? Active ...
Thomas's user avatar
  • 2,982
-1 votes
1 answer
159 views

How to query jsob column in rails using where clause

I'm trying to fetch the record which the fields are not null. for example I'm having a jsonb column in my table like this job_metadata jsonb DEFAULT '{}'::jsonb NOT NULL i want to fetch the record of ...
jansha's user avatar
  • 171
1 vote
1 answer
330 views

How to toggle a boolean field for multiple records generating just one SQL query

I'm trying to write a migration to update a boolean field where the field will mean the exact opposite of what it means currently. Therefore I need to toggle every record to update the records where ...
Breno's user avatar
  • 6,331
0 votes
2 answers
183 views

Ruby - IF or OR condition on a JOINS statement

How can I specify a OR condition on a joins statement? Basically I don't want the joins for where(:tenant_id => User.current_tenant. If I try OR condition I get the following error. I get the ...
user630702's user avatar
  • 3,187
0 votes
0 answers
73 views

Ruby - Query with multiple subqueries

How can I write a where condition query using ruby for the following SQL statement? I believe we need to define a belongs_to on the service_tempaltes model before we can query other tables? select * ...
user630702's user avatar
  • 3,187
1 vote
1 answer
903 views

Ruby - PG::UndefinedTable: ERROR: missing FROM-clause entry for table

I'm getting the following error when I'm trying to query another table in a model definition. PG::UndefinedTable: ERROR: missing FROM-clause entry for table "miq_user_roles" LINE 1: ..."...
user630702's user avatar
  • 3,187
0 votes
1 answer
260 views

migrate data from one server to another while keeping few tables data unchanged basically exclude few tables while using pg_restore

Lets say my database have 4 tables A,B,C and D..Now I want while restoring data of table A and B remains unchanged and data of C and D should changed. I am using below command to restore the dump. ...
Mahroze Shahid's user avatar
0 votes
0 answers
100 views

How to format the search input to us format phone number

as in table the phone numbers are stored in us format as (###)-###-#### and i tried to search it, as im getting the input from user as string(phone number) and i tried to convert that as search_input ...
jegan's user avatar
  • 41
2 votes
1 answer
226 views

Custom query to fetch all entries of a table and that only contains first of many duplicates based on a specific column

I have a Location model and the table looks like id name vin ip_address created_at updated_at 0 default 0 0.0.0.0/0 2021-11-08 11:54:26.822623 2021-11-08 11:54:26.822623 1 admin 1 10.108.150.143 2021-...
current_user's user avatar
  • 1,212
1 vote
0 answers
77 views

I'm not sure what is incorrect about my query statement

This is the query statement I wrote. I'm trying to get and print all post where the value of requestor == current_user.id @posts = Post.joins(user: :follows).where(follows: { requestor: current_user....
Isaiah 's user avatar
1 vote
1 answer
1k views

database.yml with postgres schema

I'm cloning a remote postgresql database to my local dev in order to run some tests, in the remote db the data I need is actually in a schema within the db, I haven't figured out how to remove schema ...
Don Giulio's user avatar
  • 3,304
0 votes
2 answers
79 views

How to get data from database with specific combination of name

I am working on ruby on rails project and I need to get data from the database with a specific combination like c*_c*_othername * can be numbered 1,2,3 etc like c1_c1_anystring. Prefix c is fixed for ...
Varinder Sohal's user avatar

15 30 50 per page
1
2 3 4 5
61