javascript - Ajax with new controller action rails -


i have created new micropost controller action called more receive ajax request.

def more   micropost=micropost.find_by(params[:id])   @answers=micropost.answers   respond_to |format|    format.html {redirect_to micropost}    format.js   end end 

and have created jquery file- more.js.erb

$(".microposts").html("<%= escape_javascript(render('users/unfollow')) %>"); ` 

to replace content partial route file like

resources :microposts, only: [:edit,:create,:destroy,:update,:show,:more]   member     :more   end end 

and call javascript file in view with

<%= link_to "load more",more_micropost_path(micropost),remote: true %>

its working normal html request not ajax.nothing happens when click on link. saw similar questions asked fixes not working me. can me this. in advance.. error in firebug console

`500 internal server error. nomethoderror in micropostscontroller#more. undefined method id nil:nilclass'

the firebug error console shows jquery line on right hand side. not sure if error.

lixhr.send( ( options.hascontent && options.data ) || null );

judging error posted in comments, line may problem:

micropost = micropost.find_by(params[:id]) 

find_by requires hash, either use find

micropost = micropost.find(params[:id]) 

or

micropost = micropost.find_by(id: params[:id]) 

Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -