📄 01 - passing data from the controller to the view.rb
字号:
class NovelController < ApplicationController def index @title = 'Shattered View: A Novel on Rails' one_plus_one = 1 + 1 increment_counter one_plus_one end def helper_method @help_message = "I see you've come to me for help." end private def increment_counter(by) @counter ||= 0 @counter += by endend#---<h1><%= @title %></h1><p>I looked up, but saw only the number <%= @counter %>.</p><p>"What are you doing here?" I asked sharply. "Was it <%=@counter.succ %> who sent you?"</p>#---class NovelController < ApplicationController @@numbers = [1, 2, 3] TITLE = 'Revenge of the Counting Numbers'end#---# config/environment.rbAUTHOR = 'Lucas Carlson'#---<h1><%= @title %></h1><p>by <%= AUTHOR %></p>...#---$one = 1class NovelController < ApplicationController $two = 2 def sequel $three = 3 endend#---Here they come, the counting numbers, <%= $one %>, <%= $two %>, <%= $three %>.#---
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -