TIM*_*MEX 3 ruby ruby-on-rails
def show
render :text => params.inspect
end
Run Code Online (Sandbox Code Playgroud)
什么是render :text =>?
什么是render,:text和=>?
它们是标准的红宝石吗?
您在该代码段中使用的语法不仅限于此render(),但它与许多其他Ruby on Rail方法相同.
该方法使用简化的语法接受哈希映射.
代码相当于
def show
render({:text => params.inspect})
end
Run Code Online (Sandbox Code Playgroud)
其他包含相同语法的代码段包括:
def sign
Entry.create(params[:entry])
redirect_to :action => "index"
end
url_for :controller => 'posts', :action => 'recent'
url_for :controller => 'posts', :action => 'index'
url_for :controller => 'posts', :action => 'index', :port=>'8033'
url_for :controller => 'posts', :action => 'show', :id => 10
url_for :controller => 'posts', :user => 'd', :password => '123'
def show
@article = Article.find(params[:id])
fresh_when :etag => @article, :last_modified => @article.created_at.utc, :public => true
end
Run Code Online (Sandbox Code Playgroud)