Software Engineer working since 2008 with Ruby / Ruby on Rails, love a bit of Elixir / Phoenix.
I also poke through other people's code and make PRs for OpenSource Ruby projects that sometimes make it. Currently working at Juniper Education making code for UK schools.
New-MacBook-Pro:mini-epic cex$ ./bin/server
=> Booting Puma
=> Rails 4.2.1 application starting in development on http://0.0.0.0:8001
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Exiting
/Users/cex/.rvm/gems/ruby-2.2.2@epic-invite/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `initialize': could not connect to server: No such file or directory (PG::ConnectionBad)
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
I tried restarting with brew
New-MacBook-Pro:mini-epic cex$ brew services restart postgresql
Stopping `postgresql`... (might take a while)
==> Successfully stopped `postgresql` (label: homebrew.mxcl.postgresql)
==> Successfully started `postgresql` (label: homebrew.mxcl.postgresql)
I was just dealing with a bug where object.mark_sent! wasn’t saving the record.
included do
include AASM
aasm(:state) do
state :in_checkout, initial: true
state :processing
state :available
state :completed
state :inactive
state :sent
event :start_processing! do
transitions from: [:in_checkout, :processing, :available], to: :processing
end
event :processed! do
transitions from: [:in_checkout, :processing], to: :available
end
event :mark_sent! do
transitions from: [:available, :completed], to: :sent
end
after_all_transitions :set_aasm_timestamp
end
end
There’s a mark_sent! event, so surely mark_sent! should change the state and save the record right? No.
event :mark_sent! do
transitions from: [:available, :completed], to: :sent
end
This actually creates two method mark_sent! which makes the state change and it’s counterpart that also saves the record mark_sent!!. You can’t call a method with a double exclamation directly.
I’ve got a really annoying DEPRECATIONWARNING. It appears the wck gem is spitting out errors and it’s no longer being updated. All I want to do is calm down the errors. The styles are all still helpful.
DEPRECATION WARNING: Extra .css in SCSS file is unnecessary. Rename /Users/cex/.rvm/gems/ruby-2.2.2@epic-invite/gems/wck-0.0.5/app/assets/stylesheets/wck.css.scss to /Users/cex/.rvm/gems/ruby-2.2.2@epic-invite/gems/wck-0.0.5/app/assets/stylesheets/wck.scss. (called from _app_views_home_index_html_haml___3330030305515264653_70130897119780 at /Users/cex/repos/epic-invite/app/views/home/index.html.haml:9)
Best course of action is to vendor the gem. So All I need to do is unpack it into my application and fix the issue.
New-MacBook-Pro:epic-invite cex$ bundle install
...
Using valid_email 0.0.11
Using wck 0.0.5 from source at `vendor/gems/wck-0.0.5`
Using whenever 0.9.4
....
The solution is to just rename the file, and satisfying to avoid seeing so many errors.
I genuinely expected Solo to be a load of old bollocks, it wasn’t as good as Rogue One but it was still better than the prequel trilogy that we don’t talk about.
Sorry that Death’s Head has a miserable head on that day.
After all this time, the way of creating users and granting privileges on user in one statement just doesn’t work anymore. I guess I just missed the memo
New-MacBook-Pro:robl cex$ mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.15 Homebrew
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> GRANT ALL ON robl.* to robl@localhost IDENTIFIED BY 'robl';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL
Ok, so we need to create the user and then do the grant
mysql> CREATE USER robl IDENTIFIED BY 'robl';
Query OK, 0 rows affected (0.01 sec)
mysql> GRANT ALL ON robl.* TO robl@localhost;
ERROR 1410 (42000): You are not allowed to create a user with GRANT
mysql> CREATE USER robl@localhost;
Query OK, 0 rows affected (0.00 sec)
mysql> CREATE USER robl@localhost iDENTIFIED BY 'robl';
ERROR 1396 (HY000): Operation CREATE USER failed for 'robl'@'localhost'
mysql> DROP USER robl;
Query OK, 0 rows affected (0.00 sec)
mysql> CREATE USER robl@localhost IDENTIFIED BY 'robl';
ERROR 1396 (HY000): Operation CREATE USER failed for 'robl'@'localhost'
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> CREATE USER robl@localhost IDENTIFIED BY 'robl';
ERROR 1396 (HY000): Operation CREATE USER failed for 'robl'@'localhost'
mysql> DROP USER robl;
ERROR 1396 (HY000): Operation DROP USER failed for 'robl'@'%'
Ok, let’s just start again.
mysql> DROP USER robl@localhost;
Query OK, 0 rows affected (0.01 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> CREATE USER robl@localhost IDENTIFIED BY 'robl';
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT ALL ON robl.* TO robl@localhost;
Query OK, 0 rows affected (0.00 sec)
mysql>
I am running through a data set which is lots of answers and trying to make the data consistent as human input is always going to be wonky from typos, spaces instead of hiphens to complete misspelling. Found this…