Rails笔记2.3

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>


 
 



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值