From 686335468c32d6855f297223af02ac76f9e5ea78 Mon Sep 17 00:00:00 2001 From: kinseyost Date: Mon, 12 Sep 2016 20:20:54 -0700 Subject: [PATCH] Demonstrates dynamic links via instance variables --- app/controllers/demo_controller.rb | 5 +++++ app/views/demo/hello.html.erb | 2 ++ app/views/demo/index.html.erb | 3 ++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/controllers/demo_controller.rb b/app/controllers/demo_controller.rb index bb7ba02..bd74b5b 100644 --- a/app/controllers/demo_controller.rb +++ b/app/controllers/demo_controller.rb @@ -7,6 +7,11 @@ def index render(:template => 'demo/hello') end def somethingRandom + @actionName = 'actionName' + render('index') + end + def actionName + @actionName = 'somethingRandom' render('index') end def other_hello diff --git a/app/views/demo/hello.html.erb b/app/views/demo/hello.html.erb index 37b6bcb..e456178 100644 --- a/app/views/demo/hello.html.erb +++ b/app/views/demo/hello.html.erb @@ -15,3 +15,5 @@ <% @array.each do |n| %> <%= n %> <% end %> + +<%= link_to('Ruby Link', {:action => 'somethingRandom'}) %> diff --git a/app/views/demo/index.html.erb b/app/views/demo/index.html.erb index 01ac67e..29b2cd3 100644 --- a/app/views/demo/index.html.erb +++ b/app/views/demo/index.html.erb @@ -1,2 +1,3 @@

Demo#index

-

Find me in app/views/demo/index.html.erb

+

Find me in app/views/demo/index.html.erb using

+<%= link_to("#{@actionName}", {:action => @actionName}) %>