From ebfb8412acc61ebf3735e25c9452536bb772f895 Mon Sep 17 00:00:00 2001 From: ogom Date: Sat, 5 Dec 2015 21:53:51 +0900 Subject: [PATCH] Add main controller --- app/assets/javascripts/main.coffee | 3 ++ app/assets/stylesheets/main.scss | 3 ++ app/controllers/main_controller.rb | 4 ++ app/helpers/main_helper.rb | 7 +++ app/views/main/index.html.erb | 3 ++ config/routes.rb | 55 +----------------------- private/static/webpack.config.js | 2 +- test/controllers/main_controller_test.rb | 9 ++++ 8 files changed, 31 insertions(+), 55 deletions(-) create mode 100644 app/assets/javascripts/main.coffee create mode 100644 app/assets/stylesheets/main.scss create mode 100644 app/controllers/main_controller.rb create mode 100644 app/helpers/main_helper.rb create mode 100644 app/views/main/index.html.erb create mode 100644 test/controllers/main_controller_test.rb diff --git a/app/assets/javascripts/main.coffee b/app/assets/javascripts/main.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/main.coffee @@ -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/ diff --git a/app/assets/stylesheets/main.scss b/app/assets/stylesheets/main.scss new file mode 100644 index 0000000..a0d94c1 --- /dev/null +++ b/app/assets/stylesheets/main.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the main controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb new file mode 100644 index 0000000..88181c2 --- /dev/null +++ b/app/controllers/main_controller.rb @@ -0,0 +1,4 @@ +class MainController < ApplicationController + def index + end +end diff --git a/app/helpers/main_helper.rb b/app/helpers/main_helper.rb new file mode 100644 index 0000000..a299266 --- /dev/null +++ b/app/helpers/main_helper.rb @@ -0,0 +1,7 @@ +module MainHelper + def pack_path(path) + url = "" + url = "http://localhost:4000/static/" if Rails.env.development? + url + path + end +end diff --git a/app/views/main/index.html.erb b/app/views/main/index.html.erb new file mode 100644 index 0000000..360f902 --- /dev/null +++ b/app/views/main/index.html.erb @@ -0,0 +1,3 @@ +
+<%= stylesheet_link_tag pack_path('app.css') %> +<%= javascript_include_tag pack_path('bundle.js') %> diff --git a/config/routes.rb b/config/routes.rb index 3f66539..5313114 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,56 +1,3 @@ Rails.application.routes.draw do - # The priority is based upon order of creation: first created -> highest priority. - # See how all your routes lay out with "rake routes". - - # You can have the root of your site routed with "root" - # root 'welcome#index' - - # Example of regular route: - # get 'products/:id' => 'catalog#view' - - # Example of named route that can be invoked with purchase_url(id: product.id) - # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase - - # Example resource route (maps HTTP verbs to controller actions automatically): - # resources :products - - # Example resource route with options: - # resources :products do - # member do - # get 'short' - # post 'toggle' - # end - # - # collection do - # get 'sold' - # end - # end - - # Example resource route with sub-resources: - # resources :products do - # resources :comments, :sales - # resource :seller - # end - - # Example resource route with more complex sub-resources: - # resources :products do - # resources :comments - # resources :sales do - # get 'recent', on: :collection - # end - # end - - # Example resource route with concerns: - # concern :toggleable do - # post 'toggle' - # end - # resources :posts, concerns: :toggleable - # resources :photos, concerns: :toggleable - - # Example resource route within a namespace: - # namespace :admin do - # # Directs /admin/products/* to Admin::ProductsController - # # (app/controllers/admin/products_controller.rb) - # resources :products - # end + root 'main#index' end diff --git a/private/static/webpack.config.js b/private/static/webpack.config.js index 05984cd..4128257 100644 --- a/private/static/webpack.config.js +++ b/private/static/webpack.config.js @@ -13,7 +13,7 @@ module.exports = { ], output: { path: __dirname + '/static/', - publicPath: '/static/', + publicPath: 'http://localhost:4000/static/', filename: 'bundle.js', hot: true }, diff --git a/test/controllers/main_controller_test.rb b/test/controllers/main_controller_test.rb new file mode 100644 index 0000000..ce24b34 --- /dev/null +++ b/test/controllers/main_controller_test.rb @@ -0,0 +1,9 @@ +require 'test_helper' + +class MainControllerTest < ActionController::TestCase + test "should get index" do + get :index + assert_response :success + end + +end