Skip to content

Instantly share code, notes, and snippets.

=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@Kievbuy
Kievbuy / text
Last active November 18, 2023 17:16
You have to kill running process
In terminal:
`lsof -wni tcp:3000`
It show all running processes
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
ruby 9666 dima 10u IPv4 65756 0t0 TCP 127.0.0.1:3000 (LISTEN)
@Kievbuy
Kievbuy / 111
Created December 14, 2018 10:28
# spec_helper.rb
include Warden::Test::Helpers
Warden.test_mode!
# test_spec
login_as(@user, scope: :user)
@Kievbuy
Kievbuy / test
Last active December 4, 2018 16:56
**New database** createdb -U postgres bd_name *Connect to DB* psql -d edu -U postgres **Connect to database in psql** \connect demo_db \c demo_db
_
@Kievbuy
Kievbuy / af
Created November 27, 2018 14:08
# README ## CheckPermission Module ## Database structure **Table** Articles { String title; Text body; Integer user_id; } **Table** Users { String name; String email; String password_digest; } **Table** Roles { String name; }
_
@Kievbuy
Kievbuy / resque
Last active November 26, 2018 13:23
# Add to app/controllers/application_controller.rb
if Rails.env.production? || Rails.env.staging?
# https://api.rubyonrails.org/v4.2/classes/ActiveSupport/Rescuable/ClassMethods.html
# https://api.rubyonrails.org/v5.2/classes/ActiveSupport/Rescuable/ClassMethods.html#method-i-rescue_from
rescue_from Exception do |exception|
render_error(exception, 500)
end
rescue_from ActionController::RoutingError,
@Kievbuy
Kievbuy / A
Created November 25, 2018 19:41
Run **rake secret** to generate a new token. Now create a new **file config/initializers/secret_token.rb** and add the following: **MyApp::Application.config.secret_key_base = '<token>'** Replace <token> with the one you just generated and replace
Run rake secret to generate a new token.
Now create a new file config/initializers/secret_token.rb and add the following:
MyApp::Application.config.secret_key_base = '<token>'
Replace <token> with the one you just generated and replace MyApp with the actual module name of your app. You can find the module name of your app at the top of config/environments/development.rb
@Kievbuy
Kievbuy / kill
Created November 25, 2018 18:12
sudo kill $(sudo lsof -t -i:3000)
sudo -u postgres createuser --superuser Myname
@Kievbuy
Kievbuy / drop
Created November 12, 2018 11:50
How to drop materialized view
DROP MATERIALIZED VIEW [ IF EXISTS ] имя [, ...] [ CASCADE | RESTRICT ]