Permalink
Browse files

set home page and redirection

  • Loading branch information...
twata701 committed Feb 18, 2014
1 parent e747ded commit e5daa476ba77883d5733811cbd06dd1806eefaa9
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
@@ -0,0 +1,3 @@
// Place all the styles related to the home controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
@@ -18,6 +18,7 @@ pre {
font-size: 11px;
}
/*
a {
color: #000;
&:visited {
@@ -28,6 +29,7 @@ a {
background-color: #000;
}
}
*/
div {
&.field, &.actions {
@@ -0,0 +1,7 @@
class HomeController < ApplicationController
def index
if user_signed_in?
redirect_to tweets_path
end
end
end
@@ -2,6 +2,7 @@
class TweetsController < ApplicationController
before_action :set_tweet, only: [:show, :edit, :update, :destroy]
before_action :check_user
# GET /tweets
# GET /tweets.json
@@ -90,4 +91,12 @@ def set_tweet
def tweet_params
params.require(:tweet).permit(:tweet_id, :in_reply_to_status_id, :in_reply_to_user_id, :timestamp, :source, :text, :retweeted_status_id, :retweeted_status_user_id, :retweeted_status_timestamp, :expanded_urls)
end
# ユーザがログインしていなければ、ホームにリダイレクト
def check_user
unless user_signed_in?
redirect_to :root
end
end
end
@@ -0,0 +1,2 @@
module HomeHelper
end
@@ -0,0 +1,5 @@
<h1>Twiceへようこそ</h1>
<p>ログインして利用を開始しましょう</p>
<%= link_to (user_omniauth_authorize_path :twitter), class: "btn btn-large btn-primary" do %>
Twitterでログイン
<% end %>
View
@@ -7,7 +7,7 @@
end
devise_for :users, :controllers => { :omniauth_callbacks => 'omniauth_callbacks' }
root :to => 'tweets#index'
root :to => 'home#index'
devise_scope :user do
get 'sign_in', :to => 'devise/sessions#new', :as => :new_user_session
@@ -1,3 +1,6 @@
auxiliary.org-netbeans-modules-css-prep.sass_2e_configured=true
auxiliary.org-netbeans-modules-css-prep.sass_2e_enabled=true
auxiliary.org-netbeans-modules-css-prep.sass_2e_mappings=/scss:/css
platform.active=Ruby_0
rails.port=3000
source.encoding=UTF-8
@@ -0,0 +1,9 @@
require 'test_helper'
class HomeControllerTest < ActionController::TestCase
test "should get index" do
get :index
assert_response :success
end
end
@@ -0,0 +1,4 @@
require 'test_helper'
class HomeHelperTest < ActionView::TestCase
end

0 comments on commit e5daa47

Please sign in to comment.