词汇:if

conj. (表条件)如果;(表假设)假如;是否;即使

相关场景

What should a tour guide do if the flight of the tour group is delayed?
>> Meeting the Guests at the Airport
what kind of preparation if necessary for a tour guide before he goes to the airport to meet an overseas tour group?
>> Meeting the Guests at the Airport
We're not gonna change that for this little example, but now let's check in that PWA files, and then let's deploy to production one more time. and as you can see, look in the top right corner, when I reload it, we now have that little install icon in Chrome. and if I click that little install icon, I'm gonna get this prompt, and boom! I have a PWA running in production for my Rails application.
>> Rails 8.0.1 You are in good company
And it's gonna refer to an icon, by default,we just have a nice red dot.but you should obviously replace that with your application. And if I hop in and have a look at the service worker, it is sort of already set up for doing we push,just as an example here, having some listeners, you can tweak that as you see fit.
它将指向一个图标,默认情况下,我们只有一个漂亮的红点。但你显然应该用你的应用程序替换它。如果我跳进去看看服务工作者,它已经为我们推送做了准备,就像这里的一个例子,有一些监听器,你可以根据需要进行调整。
>> Rails 8.0.1 You are in good company
So, it's no gonna show that button if we're not already authenticated, which is good because this layout is also used for login.
>> Rails 8.0.1 You are in good company
Now, let's add a way to sign out to the main layout here. we can add that with a button to sign out.it's gonna hit the session path, and it's gonna use a method of delete that session if we're authenticated, as you can see there.
>> Rails 8.0.1 You are in good company
Now, if we hop back onto local host, and we try to log in with first the wrong password. we're actually gonna see something here , when I added the authentication, it added another gem, it added bcrypt, that's what we're using to keep password secure, so we have to hop back in here and restart our development server!
>> Rails 8.0.1 You are in good company
If we hop to the session, you can see it just is very basic Rails active record. Now we're gonna set up a default user that the systems should have as we're working with it to allow us to log in since we don't have that signup flow.
>> Rails 8.0.1 You are in good company
By default, Kamal will use a docker volume to start these things up, but of course, you can configure that, and as I said, you can use S3 if you'd like as well.
>> Rails 8.0.1 You are in good company
If we go back here and reload not in production, boom! We are live in production with our whole setup, everything is working, we can upload the active storage files directly to it.
>> Rails 8.0.1 You are in good company
There was a 404 here! That's because if we go back to out route file, I have not defined route! And in production, you're not gonna get that screen we saw with the Rails version and the Ruby version, that is only for development.
>> Rails 8.0.1 You are in good company
And that'll connect to the remote server, and it'll install Docker if it's missing,it'll build the Docker file or Docker container off the Docker file that Rails ship with by default, there's nothing you need to set up there.
这将连接到远程服务器,如果缺少Docker,它将安装Docker,它会根据Rails默认附带的Docker文件构建Docker文件或Docker容器,你不需要在那里设置任何东西。
>> Rails 8.0.1 You are in good company
You'll need to change that if you're working with other people of course, because you don't wanna check that master key into your Git repository,you're gonna wanna pull that out of one password when you go for real.
>> Rails 8.0.1 You are in good company
It's the willingness to try and all you need is to know if you try you're not gonna die, you're just gonna learn something.
这是尝试的意愿,你所需要的就是知道如果你尝试了,你就不会死,你只会学到一些东西。
>> Confidence is action
21:28:
So this server exists on this address, servers web: - demo.exitsoftware.io ; proxy: host: alpha.exitsoftware.io; And I will then fill out the host as a C name to that machine. But we're using Alpha here, if I had deployed another application called Bravo to the same server, Kamal would set it up, so it's like I host two applications or any number of applications on that same server! Now, we will also need to have a look at the secrets here, that is in dockyml/secrets, because the register that I'm using, that is Docker Hub, needs of course a password, it is using my username but also needs a password.
>> Rails 8.0.1 You are in good company
And that is basically it. Now if I go over here and I add a comment to one of these, you see the comment was added on the left immediately at the same time. That's all web sockets automatically happening through action cable. And we can do it , of course the other way as well.
>> Rails 8.0.1 You are in good company
And if we hop into our comment, we can set up a broadcast_to for that post. The broadcast_to will broadcast all update made to that comment, whether a new comment is updated or an existing comment is changed in some way or even one deleted, and send it back out to a channel on action cable named after the post association that this comment belongs to!
>> Rails 8.0.1 You are in good company
So if we scroll down to the bottom here, we are ready. The first thing we're gonna do, we're gonna add a turbo stream from post to the show files to the show template.That's gonna set up the web socket connection and subscribe us to a channel named after that particular post that's pasted in.
>> Rails 8.0.1 You are in good company
Alright, if we hop into that comments controller, it was empty. As you can see there, I'm gonna pay something in that actually makes this stuff work! You'll see one principle of the controller setup we have is that we have these callbacks. Before action, we're gonna set posts. So before all the actions, we're going to reflect the fact that this is nested resource.
>> Rails 8.0.1 You are in good company
Now again, if you don't want any of this stuff, there is a way using JS bundler dash Rails to set things up in a more traditional way using ES build and what have you. But this is a wonderful way of developing modern web application.
>> Rails 8.0.1 You are in good company
If you look at something like hey.com, you'll see this technique in use on a major application, and you can view all of the Javascript that we use to build that application, and that's the default for Rails.
>> Rails 8.0.1 You are in good company
12:47:
but everything else, turbo and stimulus, if they're not changing, we're not downloading that. That is why no building is such an efficient way of dealing with caching.
>> Rails 8.0.1 You are in good company
inspector:
But really, what's unique here for Rails is the fact that we're using no build by default! So if I go over here in the inspector and look at the JavaScript files that are included,you can see we have the application js file with a little digest stamp on there. If we change anything that application js file, the digest is going to change, and the browser will redownload just the part!
>> Rails 8.0.1 You are in good company
zoo:
And we will give it a format for what it should do with UTC timestamp, and turning it into a local time that we can have a look at.So if I reload here, you see it is November 13th, by the time of my recording at 3:28 PM in my local time zone, but actually underneath, the time tag is gonna be in UTC. That means we can cache this, and anyone around the world will still get the time displayed in their local time.
>> Rails 8.0.1 You are in good company
But now that we've add that, let's have a look at our application JS file.That's the default setup that you have that the scaffold is going to use. And as you can see, we're using turbo-rails, we're including all the stimulus controllers, if we have any.
>> Rails 8.0.1 You are in good company