Save 36% for Black Friday! Learn more

MikeLangford

Joined

280 Experience
2 Lessons Completed
0 Questions Solved

Activity

Posted in User Avatars with ActiveStorage Discussion

Hi TL,

Did you ever find a solution for this? I am trying to figure out how to do the same thing.

Posted in How to use ActionText in Rails 6 Discussion

Hi Chris,

I've run into a weird problem after adding ActionText to my app. The second level nested comments (I followed your tutorial) on my posts will not display text for some reason. The original post displays rich text. Then, I can comment on it and the first level comment displays fine. But, if I comment on a comment no text will show up.

The old plain text, second level comments also dissappeared.

I inspected the element and it looks my code pulls in class="trix-content" and then the comment body. for the first level comment. But, on the second level there is no body being pulled in.

It's weird because these comments worked before ActionText. Any thoughts?

Posted in Display Posts on Homepage

You rock Chris! Thank you.

The second solution of routing to "posts#index" was exactly what I had in mind.

Posted in Display Posts on Homepage

I am building a social app and I want to display the content of the /posts page (index.html.erb) on the homepage if a user is logged in.

The code below works just fine on the /posts page to display the list of posts. However, when I try to use it on the Home page it throws the error "undefined method `each' for nil:NilClass"

Any suggestions on how to adjust the <% @posts.each do |post| %> so it works on the Home page? Or, should I direct users to the Posts page with a <% if user_signed_in? %> as a replacement for the home page?

<% @posts.each do |post| %>





  • <%= post.created_at.strftime("%b %e, %Y") %>
    <%= post.user.name.full %>


    <%= post.content %>


    <%= link_to 'Show', post %>
    <% if post.user == current_user %>
    <%= link_to 'Edit', edit_post_path(post) %>
    <%= link_to 'Delete', post, method: :delete, data: { confirm: 'Are you sure?' } %>
    <% end %>
    <% end %>