<%= simple_form_for [ @user ,@tweet], id: "form-submit" do |f| %>
<%= f.input :content, label: "Tweet" %>
<%= f.button :submit, class: "btn btn-danger" %>
<% end %>
<br>
<% @tweets.each do |tweet| %>
<ul>
<li>
<%= tweet.created_at.strftime("%B %d %Y, %l:%M%P") %> <br>
<%= tweet.content %>
<%= tweet.user.email %>
</li>
</ul>
<% end %>
Я делаю твиттер-клон.Я пытаюсь показать имя пользователя пользователя рядом с его твитом.Я использую devise и сделал так, чтобы пользователь вводил имя, фамилию и имя пользователя при входе в систему. Однако на консоли rails они выглядят как ноль, не зная, в чем проблема, так как я думал, что всеТо, что я добавил в контроллер приложения, было правильным.это работает, когда я делаю tweet.user.email, хотя.
<div class="form-inputs">
<%= f.input :first_name, required: true, autofocus: true , input_html: { autocomplete: "First Name" }%>
<%= f.input :last_name, required: true, autofocus: true , input_html: { autocomplete: "Last Name" }%>
<%= f.input :username, required: true, autofocus: true , input_html: { autocomplete: "Username" }%>
<%= f.input :email, required: true, autofocus: true , input_html: { autocomplete: "email" }%>
<%= f.input :password, required: true, hint: ("#{@minimum_password_length} characters minimum" if @minimum_password_length), input_html: { autocomplete: "new-password" } %>
<%= f.input :password_confirmation, required: true, input_html: { autocomplete: "new-password" } %>
</div>
и мой контроллер приложения:
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :authenticate_user!
before_action :configure_permitted_parameters, if: :devise_controller?
def configure_permitted_parameters
# For additional fields in app/views/devise/registrations/new.html.erb
devise_parameter_sanitizer.permit(:sign_up, keys: [:first_name, :last_name, :username])
# For additional in app/views/devise/registrations/edit.html.erb
devise_parameter_sanitizer.permit(:account_update, keys: [:first_name, :last_name, :username])
end
end