Skip to content

Instantly share code, notes, and snippets.

@axsuul
Forked from anirudhgaur/index.html.erb
Created February 11, 2012 23:18
Show Gist options
  • Save axsuul/1804968 to your computer and use it in GitHub Desktop.
Save axsuul/1804968 to your computer and use it in GitHub Desktop.
sending values from javascript into ruby injection
<input type="button" onclick="myfunction()" value="NEWEdit" />
<script language="javascript" type="text/javascript">
$(function() {
$(document).on('click', '#edit', function() {
$('#he').text($('#posts').data('count'));
});
});
</script>
<div id="posts" data-count="<%= params[:count] %>">
<h2 id='he'></h2>
<input type="button" id="edit" value="NEWEdit" />
class PostsController < ApplicationController
# GET /posts
# GET /posts.json
def index
@posts = Post.all
@val=params[:count].to_i
respond_to do |format|
format.html # index.html.erb
format.json { render :json => @posts }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment