ruby 是否可以在API模式下将HAML实现到Rails项目中?

g6baxovj  于 2023-04-11  发布在  Ruby
关注(0)|答案(1)|浏览(95)

如何在控制器上连接HAML模板?
我在API模式下使用Rails7,我想在我的应用程序上返回一个HTML模板
P.D:我之所以包括ActionController::Base,是因为FullStack模式下的Rails使用ActionController::Base来返回HTML模板

# app/views/tickets/ticket.html.haml

%strong= Hello World
# app/controllers/tickets_controller.rb

class TicketsController < ActionController::Base
  def index
    # (return HAML template here)
  end
end
lmyy7pcs

lmyy7pcs1#

我来解决问题!只要我这么做:

# app/controllers/tickets_controller.rb

class TicketsController < ActionController::Base
  def index
    render 'tickets/index'
  end
end

只是我把它作为一个HTML模板几乎像全栈模式

相关问题