2010年11月15日 星期一

create new hello html with instance variable and link to url

1.on deme controller add new function name hello
#vim /cms/app/controller/demo_controller.rb
add new function hell in the file

def hello
@firstArray = [1,2,3,4,5,6,7,8,9,10]
end

2.add new view on demo
#vim /cms/app/views/hello.html.rb
add new content
<% @firstArray.each do |x| %>
<%= x %><br />
<% end %>

<%= link_to('google at taiwan','http://www.google.com.tw/') %>
<br />
<%= link_to('index page','/demo/index') %>
<br />
<%= link_to('index page',{:action => 'index'}) %>
&

3.browser your web to http://192.168.1.99/demo/hello/

沒有留言:

張貼留言