我正在使用设备身份验证。我希望登录页面出现在空白页面上。所以, render ' layouts/navigation '.... <% = Render ' layouts/Topnavbar '%>..... <% = Render ' layouts/footer '% > 我不想看到这个。我怎样才能做到这一点?
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
## milia defines a default max_tenants, invalid_tenant exception
handling
## but you can override these if you wish to handle directly
rescue_from ::Milia::Control::MaxTenantExceeded, :with => :max_tenants
rescue_from ::Milia::Control::InvalidTenantAccess, :with => :invalid_tenant
before_action :authenticate_tenant!
end
应用程序.html.erb
<div id="wrapper">
<!-- Navigation -->
<%= render 'layouts/navigation' %>
<!-- Page wraper -->
<div id="page-wrapper" class="gray-bg">
<!-- Page wrapper -->
<%= render 'layouts/topnavbar' %>
<!-- Main view -->
<p class="notice"><%= notice %></p>
<%= yield %>
<!-- Footer -->
<%= render 'layouts/footer' %>
</div>
<!-- End page wrapper-->
class UsersController < ApplicationController
before_action :authenticate_user!
def index
@users = User.all
end
def show
@user = User.find(params[:id])
end
def destroy
user = User.find(params[:id])
user.destroy
redirect_to users_path, :notice => "User deleted"
end
def update
@user = User.find(params[:id])
if @user.update_attributes(secure_params)
redirect_to user_path, :success => 'User updated'
else
redirect_to user_path :alert => 'Unable to update user'
end
end
end
我明白......不幸的是它不起作用......我认为Milia gem文件不使用控件。我在路由中使用了 Milia/sessions 而不是 devise/sessions。使用 Milia 成员和用户控件。哪里渲染布局:false 不起作用
resources :members
get 'home/index'
root :to => "home#index"
# *MUST* come *BEFORE* devise's definitions (below)
as :user do
match '/user/confirmation' => 'milia/confirmations#update', :via => :put, :as => :update_user_confirmation
end
devise_for :users, :controllers => {
:registrations => "milia/registrations",
:confirmations => "milia/confirmations",
:sessions => "milia/sessions",
:passwords => "milia/passwords",
}
完全禁用登录布局
在控制台中生成设备控制器
rails generate devise:controllers [scope]
render layout: false
在new
行动结束时调用
禁用布局内的特定部分,但保留基本布局
<%= render 'layouts/navigation' if controller_name != 'milia/sessions' || action_name != 'new' %>
最好把这个条件放到 helper 中
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句