Rails笔记2.3

来源:互联网 发布:java tomcat作用 编辑:程序博客网 时间:2024/05/17 09:22

demo/app/views/say/goodbye.html.erb

<span style="font-size:14px;"><h1>Goodbye!</h1><p>    It was nice having you here.</p></span>

http://localhost:3000/say/goodbye


demo/app/views/say/hello.html.erb

...<p>    Say <a href="/say/goodbye">Goodbye</a>!</p>

demo/app/views/say/goodbye.html.erb

...<p>    Say <a href="/say/hello">Hello</a>!</p>...

demo/app/views/say/hello.html.erb

<h1>Hello from Rails!</h1><p>    It is now <%= @time %></p><p>    <%= link_to "Goodbye" ,say_goodbye_path %>!</p>


demo/app/views/say/goodbye.html.erb

<h1>Hello from Rails!</h1><p>    It is now <%= @time %></p><p>    <%= link_to "Hello" ,say_hello_path %>!</p>



We constructed a toy application that showed us the following:
  • How to create a new Rails application and how to create a new controller in that application
  • How to make dynamic content in that controller and display it via the view template
  • How to link pages together

<pre name="code" class="ruby"><h1>hello</h1><h1>It is now <%= @time %> </h1><p><%= link_to "Goodbye", say_goodbye_path %>!</p><p>Addition:<%= 1+2 %></p><p>Conctenation:<%= "cow" + "boy" %></p><p>Time in one hour:<%= 1.hour.from_now.localtime %></p>





0 0
原创粉丝点击