程序问答   发布时间:2022-06-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ActionView::SyntaxErrorInTemplate in AccountsController#profile大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决ActionView::SyntaxErrorInTemplate in AccountsController#profile?

开发过程中遇到ActionView::SyntaxErrorInTemplate in AccountsController#profile的问题如何解决?下面主要结合日常开发的经验,给出你关于ActionView::SyntaxErrorInTemplate in AccountsController#profile的解决方法建议,希望对你解决ActionView::SyntaxErrorInTemplate in AccountsController#profile有所启发或帮助;

当结束时意外结束,但我看不出问题出在哪里。 我的终端不断给我错误:ActionVIEw::SyntaxErrorInTemplate(渲染模板时遇到语法错误:

我的 profile.HTMl.erb

<% if @users.image.present?  %>
  <%= image_tag @users.image %>
<% end %>

<strong><h1><%= @users.full_name %></h1></strong>
<% if user_signed_in? %>
  <% if @user == current_user %>
    <%= link_to"Edit Profile",edit_user_registration_path(@user) %>
    <% if user_signed_in? && !@user? %>
      <% if current_user.following?(@user) %>
       <%= link_to"Unfollow",follows_path(user_iD: @user.ID),method: :delete %>
      <% else %>
       <%= link_to"Follow",follows_path(user_iD: @user.ID) %>
     <% end %>
    <% end %>
  <% end %>
<% end %>
<div> <%= @users.posts.count %> posts </div>
<p><%= @users.full_name %></p>
<p><%= @users.description %></p>
<p><%= link_to @users.website if @users.website.present? %></p>
<%= @posts.each do |post|%>
<%= image_tag post.image %>
<% end %> 

解决方法

问题似乎在这里

<p><%= link_to @users.website if @users.website.present? %></p>

改成

<p><%= link_to 'User Website',@users.website if @users.website.present? %></p> 
,
<% if user_signed_in? && @user == current_user %>

      <%= link_to"Edit Profile",edit_user_registration_path(@user) %>
    <% if current_user.following?(@user) %>
        <%= link_to"Unfollow",follows_path(user_id: @user.id),method: :delete %>
    <% else %>
        <%= link_to"Follow",follows_path(user_id: @user.id) %>
    <% end %>
<% end %>

现在好了:D

,

我看到了两个错误,请纠正。首先,没有什么 @user? 是最大的错误,另一个可能不是问题,但没有空间 <%= link_to"Edit Profile" 请尝试以下代码,我已更改内容并正确重新格式化。

<% if @users.image.present? %>
  <%= image_tag @users.image %>
<% end %>

<strong><h1><%= @users.full_name %></h1></strong>

<% if user_signed_in? %>
  <% if @user == current_user %>
    <%= link_to "Edit Profile",edit_user_registration_path(@user) %>
    <% if user_signed_in? && !@user %>
      <% if current_user.following?(@user) %>
        <%= link_to"Unfollow",method: :delete %>
      <% else %>
        <%= link_to"Follow",follows_path(user_id: @user.id) %>
      <% end %>
    <% end %>
  <% end %>
<% end %>

<div> <%= @users.posts.count %> Posts </div>
<p><%= @users.full_name %></p>
<p><%= @users.description %></p>
<p><%= link_to @users.website if @users.website.present? %></p>
<%= @posts.each do |post|%>
  <%= image_tag post.image %>
<% end %>

大佬总结

以上是大佬教程为你收集整理的ActionView::SyntaxErrorInTemplate in AccountsController#profile全部内容,希望文章能够帮你解决ActionView::SyntaxErrorInTemplate in AccountsController#profile所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。