【发布时间】:2016-10-01 04:01:29
【问题描述】:
我想将我的“计划”应用到一个单独的部分或者完全是一个新的文件/位置。此页面或部分页面应通过登录页面上的按钮访问。 目前,如果用户未登录,我的“计划”html 设置为有条件地显示在我的主页上。由于“before_action :authenticate_user!”我在主页上,查看“else”(里面有图)不能查看。我应该将计划分开到单独的页面上并删除条件语句吗?或者我应该把它分出来并在我的 else 语句中呈现视图?
我需要提供其他信息吗?
我是否使用了正确的术语?
home.html.erb
<div class="row">
<% if user_signed_in? %>
<%= render 'users/home' %>
<% else %>
<!--Plans-->
<div class="row">
<div class="col-lg-3">
<div class="well text-center">
<!--Plan #1-->
<%= link_to "REGISTER", new_user_registration_path(plan: @contributor_plan.id), class:'btn btn-info btn-block' %>
<!--Plan #2-->
<%= link_to "REGISTER", new_user_registration_path(plan: @elitecontributor_plan.id), class:'btn btn-warning btn-block' %>
<!--Plan #3-->
<%= link_to "REGISTER", new_user_registration_path(plan: @technician_plan.id), class:'btn btn-info btn-block' %>
<!--Plan #4-->
<%= link_to "REGISTER", new_user_registration_path(plan: @elitetechnician_plan.id), class:'btn btn-info btn-block' %>
</div>
</div>
</div>
<% end %>
pages_controller.rb
class PagesController < ApplicationController
before_action :authenticate_user!, except: [:landing, :plans]
def landing
end
def plans
end
def home
@contributor_plan = Plan.find(1)
@elitecontributor_plan = Plan.find(2)
@technician_plan = Plan.find(3)
@elitetechnician_plan = Plan.find(4)
@center_plan = Plan.find(5)
@elitecenter_plan = Plan.find(6)
@affair_plan = Plan.find(7)
@eliteaffair_plan = Plan.find(8)
end
【问题讨论】:
标签: ruby-on-rails ruby if-statement devise conditional