根据《[ruby on rails] 跟我学之路由映射》,我们知道,可以访问 GET /posts/:id(.:format) 来显示具体的对象。 修改 app/controllers/posts_controller.rb的show这个action。这里有个难题,如果获取url里面的参数?可以通过params内置变量进行访问
参考数据:对于Ruby On Rails 不是粉清楚的朋友可以参考以下的连结信息,该连结网站都提供不错的Ruby On Rails 信息。Ruby: 一个纯OO的脚本语言..Ruby on Rails: 快速建置Web的MVC架构的Framework说明:整合环境: Instant Rails 是在Windows环境中,整合了Ruby,
article = nilarticle.nil?# = trueempty? checks if an element - like a string or an array f.e. - is empty:# Array[].empty? #= true# String"".empty? #= trueRails adds the method blank? to the Object class:An object is blank if it‘s false, em
path="test.txt"port=open(path)beginport.each_line{|line|p line.to_s}ensureport.closeendSTDOUT"i love you \n"port=open('test.txt')s=port.statp s.ftypep s.devp s.inop s.modep s.nlinkbegina=port.readlinesa=port.each{|e| p e}ensu
a = [1,2,3,4]-----------------------------------------------b,c = a = b=1,c=2当右边只有一个数组,ruby自动将右边的数组拆分,然后赋值给左边的变量-----------------------------------------------b,*c = a =b=1 ,c=[2,3,4]当左边变量