Skip to content

Commit

Permalink
Demonstrates dynamic links via instance variables
Browse files Browse the repository at this point in the history
  • Loading branch information
kinseyost committed Sep 13, 2016
1 parent 7b9477b commit 6863354
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions app/controllers/demo_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions app/views/demo/hello.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@
<% @array.each do |n| %>
<%= n %>
<% end %>

<%= link_to('Ruby Link', {:action => 'somethingRandom'}) %>
3 changes: 2 additions & 1 deletion app/views/demo/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
<h1>Demo#index</h1>
<p>Find me in app/views/demo/index.html.erb</p>
<p>Find me in app/views/demo/index.html.erb using </p>
<%= link_to("#{@actionName}", {:action => @actionName}) %>

0 comments on commit 6863354

Please sign in to comment.