Recommended File Extension for rails view pages(2.

2019-08-01 18:04发布

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

1.RHTML
2.html.erb

any significance in this.

2条回答
看我几分像从前
2楼-- · 2019-08-01 18:15

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

查看更多
相关推荐>>
3楼-- · 2019-08-01 18:16

afaik, .rhtml has long been deprecated.

查看更多
登录 后发表回答