Activity
Hey Ariff,
Haven't recorded that yet, it kinda slipped my mind. Let me get on that this week!
Lots more Vue coming, I really really enjoy using it on the frontend. It feels refreshing to work with for once.
Posted in RSpec w/capybara vs Mini Test
I'm generally pretty torn on the two. Rspec is great because there are so many examples out there, but I really really dislike the DSL it adds because it obfuscates a lot. Minitest is great because it's just plain Ruby where you can refactor all your work like you regularly would.
I guess generally that leads me to suggest Rspec if you're new and Minitest if you're good at Ruby.
@Nick, I feel the same way about TDD. It doesn't add much for me which is why I generally just add tests as I need rather than doing full blown TDD.
For now, I'm just using Uservoice for this, but it isn't the best and is just in the Feedback link in the footer (https://gorails.uservoice.com/forums/259979-general). I'm definitely planning on improving this and making it part of the site in the near future.
I love the idea of showing what episodes I'll be recording for the future couple of weeks. That would be really handy I'm sure.
Jacob is exactly right. :D
And just a quick note: generally you use these url params to do filtering (like pagination) or sorting or you'd use them to turn on and off simple features like autoplaying of videos like you see on here.
Then sometimes it's nicer to have a full path dedicated to a section to designate it's importance so I'll tend to do that for things like forum categories. Rather than just saying /forum?category=rails
I've got /forum/category/databases
to kind of denote that it's a dedicated page.
It's late so I don't know if I'm explaining that bit well, so here's a stack overflow post that describes the same thing: http://webmasters.stackexchange.com/a/15394
Awesome! Also hadn't heard of this library before, it looks slick!
The JWT gem we use verifies the signature every time you call decode on it, so every token is verified, as well as the expirations and other features it supports. It's fine to have multiple tokens per user (one for each device for example) but because things can change you want to use expirations so they can get a more recent version of the token. There's no need to store anything server-side in the db because this is designed to be stateless.
Does that make more sense?
AMS doesn't care about your URLs, it just takes models and turns them into JSON. You can use any routes you want. Ideally for JSON:API spec, you'll want some restful routes for the objects, but it's also fine to have routes like you mentioned for ease of use. I think of routes for concepts often, it doesn't have to be specifically for a model. For example, your routes make sense because they offer up clear endpoints for different concepts for each one.
Haha crap, bad edit!
Interestingly, there isn't a stop_stream method in ActionCable, so you'd have to stop all streams at least right now. Someone has opened a PR with this but it's still pending: https://github.com/rails/ra...
For now, I guess you can either stop_all_streams and reconnect to the ones you want, or you can monkey patch in the code from that pull request. I would probably do that because it's likely to get accepted.
And to implement the disconnect, you'd just send the message from the JS to call a method in the server side channel to call the stop stream. This would look almost exactly like sending a message, you'd just pass in the name of the channel you want to remove.
Yeah, data-confirm is just a generic attribute you can use on any clickable item, not just delete links. That should work fine.
Turns out it doesn't have access to the session, so you can't use that. http://edgeguides.rubyonrails.org/action_cable_overview.html#notes
You can probably do the signed cookies like the article there mentions as an alternative. That's how things work with Devise.
cookies.signed[:user_id]
instead but also has to change in your controllers as well.
Update: Here's an example on StackOverflow: http://stackoverflow.com/questions/37671504/getting-authlogic-to-work-with-actioncable
So you set your user id in the session
. Just use that to look up the user for the websocket:
def find_verified_user
if current_user = User.find(session[:user_id])
current_user
else
reject_unauthorized_connection
end
end
Thanks Emmanuel! I appreciate it a lot and you're right, we're always learning especially with how fast this industry changes! :D
Hmmm, double check that you restarted nginx and that went correctly. If so, it should pick that up.
Posted in Does anyone have tips on setting up redis and sidekiq on a Digital Ocean ubuntu 16.04 droplet?
Yeah, there's a few options like that. I like not having to add another dependency, plus this is nice if you're already us it to run things like Redis, etc.
Posted in Does anyone have tips on setting up redis and sidekiq on a Digital Ocean ubuntu 16.04 droplet?
Basically at this point now, you'll need to use systemd to manage Sidekiq. It will make sure it starts or if it dies, it will restart it. This is nice, but kind of confusing sometimes how to get it setup.
I have this in /etc/systemd/system/sidekiq.service
and you can enable it and manage it using the commands at the top there.
#
# systemd unit file for CentOS 7, Ubuntu 15.04
#
# Customize this file based on your bundler location, app directory, etc.
# Put this in /usr/lib/systemd/system (CentOS) or /lib/systemd/system (Ubuntu).
# Run:
# - systemctl enable sidekiq
# - systemctl {start,stop,restart} sidekiq
#
# This file corresponds to a single Sidekiq process. Add multiple copies
# to run multiple processes (sidekiq-1, sidekiq-2, etc).
#
# See Inspeqtor's Systemd wiki page for more detail about Systemd:
# https://github.com/mperham/inspeqtor/wiki/Systemd
#
[Unit]
Description=sidekiq
# start us only once the network and logging subsystems are available,
# consider adding redis-server.service if Redis is local and systemd-managed.
After=syslog.target network.target
# See these pages for lots of options:
# http://0pointer.de/public/systemd-man/systemd.service.html
# http://0pointer.de/public/systemd-man/systemd.exec.html
[Service]
Type=simple
WorkingDirectory=/home/deploy/myapp/current
# If you use rbenv:
ExecStart=/home/deploy/.rbenv/shims/bundle exec "sidekiq -e production"
User=deploy
Group=deploy
UMask=0002
# if we crash, restart
RestartSec=1
Restart=on-failure
# output goes to /var/log/syslog
StandardOutput=syslog
StandardError=syslog
# This will default to "bundler" if we don't specify it
SyslogIdentifier=sidekiq
[Install]
WantedBy=multi-user.target
Not that you'll need to change the WorkingDirectory
option for the location of your app and this assumes you're using rbenv
on your server for running Ruby.
This setup is for only accepting tokens to authenticate on the API. You can just pass over the Authorization header in Postman to test it out. You'll need a valid token, but just pass in "Authorization: bearer YOURTOKEN" as the header and that should do it.
Btw, the other episode I posted today shows how you can take this code and add it as a Devise strategy so you can use tokens to authenticate with Devise alongside cookies. Check that one out so you can see how to use Devise with it. :)
Posted in Slack forum notifications
In Slack, just add yourself to the #gorails-forum
channel. 💪
Posted in How do I send Prawn pdf via email
Just like you would do with sending any other email. You can read more on the guides page: http://guides.rubyonrails.org/action_mailer_basics.html