【问题标题】:Syntax Error while implementing devise with my ruby on rails appication使用我的 ruby​​ on rails 应用程序实现设备时出现语法错误
【发布时间】:2013-04-16 02:10:11
【问题描述】:

我正在尝试在我的 Rails 应用程序中实现设计,但在我的 header.html.erb 中出现此语法错误

    <% if user_signed_in? %>
    Logged in as <strong><%= current.user.email %></strong>.
    <%= link_to 'Edit profile', edit_user_registration_path %>
    <%= link_to 'Logout', destroy_user_session_path, method: :delete %>
<% else %>
    <%= link_to 'Sign up', new_user_registration_path %> | 
    <%= link_to 'Login', new_user_ssession_path %>
<% end %>

这是我收到的错误消息:

编译错误 /Users/ryanoliver/repos/joyties/app/views/layouts/application.html.erb:14: 语法错误,意外 ':',期待 ')' ...roy_user_session_path, 方法: :delete );@output_buffer.safe...

非常感谢任何帮助

谢谢

【问题讨论】:

    标签: ruby-on-rails-3 devise


    【解决方案1】:

    current 之间有一个点 (.)。 email 此外,您在结束标记后多了一个点 (.)

     Logged in as <strong><%= current.user.email %></strong>. <------
    

    应该是

    Logged in as <strong><%= current_user.email %></strong>
    

    这是你问题的根源;)

    为了使它也更好一点,你可以有一个 我的帐户 页面。为此,您将拥有类似

    &lt;%= link_to 'My Account', user_path(current_user) %&gt;

    最终输出:

    <% if signed_in? %>
            Logged in as <strong><%= current_user.email %></strong>
            <%= link_to 'Edit profile', edit_user_registration_path %>
            <%= link_to 'My Account', user_path(current_user) %>
            <%= link_to 'Logout', destroy_user_session_path, method: :delete %>
        <% else %>
            <%= link_to 'Sign up', new_user_registration_path %> | 
            <%= link_to 'Login', new_user_ssession_path %>
        <% end %>
    

    【讨论】:

      猜你喜欢
      • 2020-04-12
      • 1970-01-01
      • 2014-09-27
      • 1970-01-01
      • 2017-06-20
      • 2012-05-13
      • 2010-09-12
      • 2014-06-27
      • 1970-01-01
      相关资源
      最近更新 更多