Created
November 14, 2016 00:36
-
-
Save dmoney/a992748c7b59bc4f661ad2b2f0ff487a to your computer and use it in GitHub Desktop.
refreshylist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<table> | |
<thead> | |
<tr> | |
<th>Item</th> | |
</tr> | |
</thead> | |
<tbody> | |
<% @list.each do |item| %> | |
<tr> | |
<td><%= item %></td> | |
</tr> | |
<% end %> | |
</tbody> | |
</table> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<table> | |
<thead> | |
<tr> | |
<th>Item</th> | |
</tr> | |
</thead> | |
<tbody> | |
<% @list.each do |item| %> | |
<tr> | |
<td><%= item %></td> | |
</tr> | |
<% end %> | |
</tbody> | |
</table> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HomepagesController < ApplicationController | |
before_action :set_items, only: [:index, :div] | |
layout 'application', except: :div | |
# GET /homepages | |
# GET /homepages.json | |
def index | |
end | |
def div | |
end | |
private | |
def set_items | |
@list = (1..5).collect { |_| rand 0..10} | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p id="notice"><%= notice %></p> | |
<h1>Homepage</h1> | |
<div id="list_container"> | |
<%= render 'homepages/div' %> | |
</div> | |
<br> | |
<button onclick="$('#list_container').load('/homepages/div');">Refresh</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rails.application.routes.draw do | |
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html | |
get '/homepages', to: 'homepages#index' | |
get '/homepages/div', to: 'homepages#div' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment