设计:将页面注册为欢迎/着陆页面,然后到用户个人资料 [英] Devise: Sign Up Page as Welcome/Landing Page then to User Profile

查看:184
本文介绍了设计:将页面注册为欢迎/着陆页面,然后到用户个人资料的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用设计,我如何将我的注册作为登陆/欢迎页面,然后在注册后他们进入该网站进入个人资料/签名区域?

Using devise, how do i make my Sign Up as my landing/welcome page and then after sign up they go inside the site to the Profile/signed in area?

我正在试图弄清楚如何让Facebook成为Facebook两面的网站;在注册或登录后,外部(注册,关于,联系人等)和内部(配置文件,注销等)仅供用户使用。

I am trying to figure out how to make it like where Facebook their is two sides of the website; the Outside (sign up, about,contact,etc) and The Inside (Profile,sign out,etc) for Users only after sign up or sign in.

谢谢。

PS我是Ruby on Rails和创建应用程序的新功能,但是我已经使用Rails 3教程进行了身份验证系统,我理解大多数事情要开始使用Devise,我不知道从哪里开始这种情况。

P.S. I am new at Ruby on Rails and creating applications but i did do the authentication system with the Rails 3 Tutorial, i understand most things to start using Devise, i jst dont know where to start with this situation.

我将使用2个应用程序布局,1个注册之前是layout / welcome.html.erb与PagesController(约,术语等),另一个用ApplicationController(profile,news,add等)进行布局/ application.html.erb的用户登录,这是最好的步骤吗?

I was going to use 2 application layouts, 1 before sign up which is layouts/welcome.html.erb with PagesController (about,terms,etc) and the other for signed in users which will be layouts/application.html.erb with ApplicationController (profile,news,add,etc), is this the best steps?

推荐答案

这是我使用Rails的新的和更新的方式 3.1.0 和Devise 1.5.0

This my new and updated way using Rails 3.1.0 and Devise 1.5.0:

routes.rb

root :to => "pages#redirect_to_sign_up"

devise_for :users do
  get "welcome" => "devise/registrations#new", :as => :new_user_registration
  get "account_settings" => "devise/registrations#edit"
  get "sign_in" => "devise/sessions#new"
  get "sign_out" => "devise/sessions#destroy"
  get "new_password", :to => "devise/passwords#new"
end

match 'home',      :to => "user_pages#home"

namespace :user do
  root :to => "user_pages#home"
end

application_controller.rb / p>

application_controller.rb

class ApplicationController < ActionController::Base
  protect_from_forgery

  protected

  def after_sign_in_path_for(resource)
    stored_location_for(:user) || root_path
  end

  private

  def after_sign_out_path_for(resource)
    stored_location_for(:user) || root_path
  end
end

pages_controller.rb

class PagesController < ApplicationController
  def redirect_to_sign_up
    if signed_in?.blank?
      redirect_to new_user_registration_path
    else
      redirect_to home_path
    end
  end
end

user_pages_controller.rb

class UserPagesController < ApplicationController
  before_filter :authenticate_user!

  def home
  end

  def profile
  end
end

这篇关于设计:将页面注册为欢迎/着陆页面,然后到用户个人资料的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆