词汇:post
n. 岗位;邮件;标杆
相关场景
"Following the premature death of His Excellency, the Governor of Coventry Island, "we hear the post is to be offered to the distinguished veteran of Waterloo, Colonel Rawdon Crawley."
>> Vanity Fair 名利场 Movie Script
>> Vanity Fair 名利场 Movie Script
Miss Sharp, I can't pretend to understand... why you prefer the post of a country governess to your position here.
>> Vanity Fair 名利场 Movie Script
>> Vanity Fair 名利场 Movie Script
OUTSIDE the fire is driven by the rotor-wash toward JAKE and GRACE who are still bound tightly to the posts.
>> 阿凡达 Avatar Movie Script
>> 阿凡达 Avatar Movie Script
IN THE DRAGON COCKPIT Quaritch watches a targeting screen -- a telescopic image of Jake and Grace tied to posts.
>> 阿凡达 Avatar Movie Script
>> 阿凡达 Avatar Movie Script
EXT. HOMETREE JAKE and GRACE are lashed to posts at the front entrance to Hometree. The People look up as -- THE DRAGON and its escort of GUNSHIPS arrive over the trees.
>> 阿凡达 Avatar Movie Script
>> 阿凡达 Avatar Movie Script
(rallying) Stand to your posts! Do not give in to fear. Fight!
>> 指环王3:王者归来The Lord of the Rings: The Return of the King Movie Script
>> 指环王3:王者归来The Lord of the Rings: The Return of the King Movie Script
(yelling) Return to your posts!
>> 指环王3:王者归来The Lord of the Rings: The Return of the King Movie Script
>> 指环王3:王者归来The Lord of the Rings: The Return of the King Movie Script
DENETHOR (cont'd) (panicked scream) Abandon your posts!
>> 指环王3:王者归来The Lord of the Rings: The Return of the King Movie Script
>> 指环王3:王者归来The Lord of the Rings: The Return of the King Movie Script
So in production, you actually need to manually specify the route. So we can go down here, and uncomment this, that sets what the route is going to be, we're just gonna point it to post stud index.
>> Rails 8.0.1 You are in good company
>> 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
>> 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
>> Rails 8.0.1 You are in good company
When it is nested, we get the fact that it's gonna be slash post slash on slash comments, and we have the association is set up nicely. Now, let's reload! Now it works, we have our comments field underneath. we can add the first comment. And as you can see here, this is my first comment a second ago that was the local time doing its time ago conversion.
>> Rails 8.0.1 You are in good company
>> Rails 8.0.1 You are in good company
当它被嵌套时,我们得到的事实是,它将是斜线后斜线对斜线注释,并且我们已经很好地建立了关联。现在,让我们重新加载!现在它工作了,我们在下面有我们的评论字段。我们可以添加第一条评论。正如你在这里看到的,这是我一秒钟前的第一条评论,当时当地时间正在进行时间转换。
Now that we have that up, we can hop in and look it all up into the show action for the posts! That's gonna reference that common slot comments, that includes both the comments and the new form.
>> Rails 8.0.1 You are in good company
>> Rails 8.0.1 You are in good company
And then finally, let's paste in the form that we're gonna use. That form is going off a model, the new comment, but it's nested underneath the post, is that we automatically can deduce which URL that we should post this new form to.
>> Rails 8.0.1 You are in good company
>> Rails 8.0.1 You are in good company
We are pacing in the comment, and we're using that same time tag as we were using with the post, but this time, we are going to use time ago, so we get that nice two minutes ago on when something went posted rather than a local time spelled out with AM PM set up.
>> Rails 8.0.1 You are in good company
>> Rails 8.0.1 You are in good company
Now, we're also gonna add a number of partials here. This is the templating system, basically, a sub-routine that you can refer to. There's gonna be three of them that includes the entire comment section. We're gonna reference that in our post show in just a second. And within that, we're gonna refer to another partial for an individual comment, and another partial again for the new setup. So, let's paste some of that in here, You can see this for the entire collection, it just has an H2 for the comments, and we render the post comments. This again uses Rails' convention over the configuration approach.
>> Rails 8.0.1 You are in good company
>> Rails 8.0.1 You are in good company
So let's actually also create the other direction of this association. You saw a comment belongs to a post, but then we're also gonna make the post has many comments. Now, we have a bidirectional association that we can work with in both ways.
>> Rails 8.0.1 You are in good company
>> Rails 8.0.1 You are in good company
The comments is something that belongs to a post, and we will pull out the post ID from the params, that's what's being parsed in as part of the URL, and we will fetch that post, and now we will create the comments associated with that post based on the parameters that are expected as comment content. And then after it's created, we will direct back to the post!
>> Rails 8.0.1 You are in good company
>> 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
>> Rails 8.0.1 You are in good company
And then, Rails by default also adds two timestamps that it keeps track of by itself, created at and updated at. And below that, you had the post that we added originally.
>> Rails 8.0.1 You are in good company
>> Rails 8.0.1 You are in good company
So, let's run the migration for that, that sets up the comments table. You can see here the schema that we've now built up. We've added a number of tables for action text and action storage. And then, we have added a comments table. That's what you can see here. As we had it in the migration where we were just referencing the post as a foreign key, and then we had the content as text.
>> Rails 8.0.1 You are in good company
>> Rails 8.0.1 You are in good company
<%=time_tag post.updated_at, "data-local": "time", "data-format": "%B %e, %Y %l:%M%P" %>
>> Rails 8.0.1 You are in good company
>> Rails 8.0.1 You are in good company