Recommended File Extension for rails view pages(2.3.2)

自闭症网瘾萝莉.ら 提交于 2019-12-11 13:34:19

问题


Which is the Recommended File Extension for rails view pages(2.3.2)

1.RHTML
2.html.erb

any significance in this.


回答1:


The standard naming:

template_name.mime_type.erb

Significance:

The controller will look for appropriately named template file when responding to different request formats:

def show
    @user = User.find(params[:id])

    respond_to do |format|
      format.html # Looks for show.html.erb
      format.xml # this will look for show.xml.erb
      # OR you can always use render :xml facility
      # format.xml  { render :xml => @user }
    end
end

Link for API Docs: http://api.rubyonrails.org/classes/ActionController/MimeResponds/InstanceMethods.html




回答2:


afaik, .rhtml has long been deprecated.



来源:https://stackoverflow.com/questions/1346075/recommended-file-extension-for-rails-view-pages2-3-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!