Q:

rails javascript not working

i am using rails 4 and ruby1.9.3:
when running the rails app on webrick the javascript did not work .
so i did some troubleshooting to focus on the problem.
1)when i run inspect element i saw the correct file is included (feast.js)
  so i guess the problem is not with asset pipeline.
i try to run a simple function called "addy" that is supposed to make an alert messege
but inspit that i can see that the js file is included (i included it on head part of the document and also on the buttom of the body part) when i press the link nothing as if the js files has no effect:
feast.js file:
// this is something i commented out
//$function()(
//$(".add_participants").on("click", function(evt) {
          var searchWindow = window.open("http://users/search","","","");
          //in the search method create a javascript with the 
          //search window object as  
          //"searchWindow.opener.location.reload" so to reload
          //the opener page.
          // location.reload(true) will get it again from cached 
          // but i think its not needed

  //          });

$function remove_fields(link){
    $(link).prev().attr({value: 1});
$(link).parent.hide;

}

function addy(){
    alert('hello');
}  

and the layout rendered(only the part of the js include tag): 
<head>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>the amazing COOK BOOK <%= "| #{@username}" if @username %></title>
         <meta name="author" content="elad bezalel">
         <%= javascript_include_tag('application')%>
         <%= stylesheet_link_tag('login') %>
    </  head>

application.js file:
 // This is a manifest file that'll be compiled into application.js, which will include        
all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts,     
vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a     
relative path.
 //
// It's not advisable to add code directly here, but if you do, it'll appear at the    
bottom of the
 // the compiled file.

//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK    
LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require jquery_ujs
//= require_tree .
//

inspect elements( in the relevant view generated as viewed in the browser):
<head>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>the amazing COOK BOOK </title>
      <meta name="author" content="elad bezalel">
<script src="/assets/jquery.js?body=1"></script>
<script src="/assets/jquery_ujs.js?body=1"></script>
<script src="/assets/feast.js?body=1"></script>
<script src="/assets/feast_invt.js?body=1"></script>
<script src="/assets/friend_invt.js?body=1"></script>
<script src="/assets/messeges.js?body=1"></script>
<script src="/assets/participation.js?body=1"></script>
<script src="/assets/posts.js?body=1"></script>
<script src="/assets/public.js?body=1"></script>
<script src="/assets/replies.js?body=1"></script>
<script src="/assets/application.js?body=1"></script>
     <link href="/assets/login.css?body=1" media="screen" rel="stylesheet">
</head>

and the view:
  <h1>let the feast begin!!</h1>
  <p>please enter all feast deatails</p><br />
  <%= form_for(:feast, :url=>{:action=>'create'}) do |f|%>

    <%=f.label("feast time", :feast_time)%><br /><br />
    <%= f.datetime_select(:feast_time, :order => [:day, :month ,:year]) %>
            <br /><br />

    <%=f.label("feast place", :feast_place)%><br /><br />
    <%= f.text_field(:feast_place) %> <br /><br />

 <%=submit_tag("start the feast")%>
<%end%> <!-- form end -->

  <%= link_to("addy",'#', :onclick => "addy(); return true;") %>
 <p>

 </p> 

i also tried 
link_to_function("addy","addy();")

yet the javascript is not working...
what is the problem????????????

A:

I would check the javascript console for an error. Also, in the javascript console you can just try stuff out, like just type your method addy();. 
That being said, your javascript code looks completely wrong: you wrote $function and I think you ment function. So your javascript parsing will fail, an error will be logged in the console, and the parsing will not even reach the defintion of addy. 

