我想在Rails5 api模式下使用视图

时间:2017-08-08 08:53:33

标签: ruby-on-rails ruby ruby-on-rails-5

尝试

routes.rb

Rails.application.routes.draw do
  get 'welcome/index'

 root to: 'welcome#index'
 resource :lookouts do
   collection do
     get :cover
   end
 end
end

welcome_controller.rb

class WelcomeController < ApplicationController
  def index
    render :html
  end
end

welcome/index.html.erb

 <!-- Compiled and minified CSS -->
 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.1/css/materialize.min.css">

 <!-- Compiled and minified JavaScript -->
 <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.1/js/materialize.min.js"></script>

 <h1>hello</h1>

如何在rails 5 api模式下使用erb模板 我听说我们不能在rails5 api模式下使用erb,但我想使用。

0 个答案:

没有答案