This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=> #<ActiveRecord::Associations::HasOneAssociation:0x000000011ca70810 | |
@association_scope=nil, | |
@disable_joins=false, | |
@loaded=true, | |
@owner=#<Poll:0x000000011c9b7658 id: 1, multiple: true, created_at: 2023-04-23 15:42:11.863742 UTC, updated_at: 2023-04-23 15:42:11.863742 UTC>, | |
@reflection= | |
#<ActiveRecord::Reflection::HasOneReflection:0x000000011e490510 | |
@active_record=Poll(id: integer, multiple: boolean, created_at: datetime, updated_at: datetime), | |
@class_name="Post", | |
@foreign_key="poll_id", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=> #<ActiveRecord::Associations::HasOneAssociation:0x000000011ca70810 | |
@association_scope=nil, | |
@disable_joins=false, | |
@loaded=true, | |
@owner=#<Poll:0x000000011c9b7658 id: 1, multiple: true, created_at: 2023-04-23 15:42:11.863742 UTC, updated_at: 2023-04-23 15:42:11.863742 UTC>, | |
@reflection= | |
#<ActiveRecord::Reflection::HasOneReflection:0x000000011e490510 | |
@active_record=Poll(id: integer, multiple: boolean, created_at: datetime, updated_at: datetime), | |
@class_name="Post", | |
@foreign_key="poll_id", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
begin | |
require "bundler/inline" | |
rescue LoadError => e | |
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler" | |
raise e | |
end | |
gemfile(true) do | |
source "https://rubygems.org" | |
gem "rails", "7.0.4.2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# User attributes name surname | |
class User < ApplicationRecord | |
end | |
class Guest | |
def name | |
'test' | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module M | |
def test | |
end | |
module B | |
def hard_test | |
puts "hey, bro" | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ApplicationRecord.transaction do | |
user.update(name: "test_user") | |
order.update(user_id: user.id) | |
CalculatePayoutJob.perform_later(user, order) | |
raise ActiveRecord::Rollback if order.errors.present? | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create database tmp_db1; | |
\c tmp_db1; | |
CREATE TABLE users ( | |
id integer, | |
email varchar(255) | |
); | |
CREATE TABLE stats ( | |
id integer, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE orders ( | |
id integer, | |
name varchar(255), | |
address varchar(255) | |
); | |
CREATE TABLE order_items ( | |
id integer, | |
price integer, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE tmp4(tmp_id integer); | |
insert into tmp4 (tmp_id) values (1), (2), (null); | |
select count(order_id <> 1) from (values (null),(1),(2)) t(order_id); | |
count | |
------- | |
2 | |
select count(*) from tmp4 where tmp_id <> 1; | |
count |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE tmp4(tmp_id integer); | |
insert into tmp4 (tmp_id) values (1), (2), (null); | |
select count(tmp_id <> 1) from tmp4; | |
select count(*) from tmp4 where tmp_id <> 1; |
NewerOlder