I’m getting an ActionviewTemplate error when trying to POST using an ajax response. The ‘create’ method keeps looking for the default create.js.erb file but I’ve specifically pointed to the file it should render.
I tried adding “end and return” to my respond_to blocks but nothing happens.
Started POST "/appreciations" for 127.0.0.1 at 2011-11-25 13:30:09 -0700
Processing by AppreciationsController#create as JS
Parameters: {"utf8"=>"✓", "authenticity_token"=>"T3PeKRaSJSrESFTOCQ7+4LiM4BKaWkcaQ6cXpSqK38k=", "appreciation"=>{"liked_id"=>"75"}, "commit"=>"Like"}
User Load (1.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = 3 LIMIT 1
Completed in 343ms
ActionView::MissingTemplate (Missing template appreciations/create with {:handlers=>[:erb, :rjs, :builder, :rhtml, :rxml, :haml], :formats=>[:js, "application/ecmascript", "application/x-ecmascript", "*/*"], :locale=>[:en, :en]} in view paths "/Users/iHal/Desktop/WORK/GP/app/views"
Appreciatins controller
class AppreciationsController < ApplicationController
before_filter :authenticate_user!
def create
if params[:liked_id]
@post = Post.find(params[:appreciation][:liked_id])
current_user.like!(@post)
respond_to do |format|
format.html { redirect_to @post }
format.js { render :action => "create_like" }
end
elsif params[:voted_id]
@post = Post.find(params[:appreciation][:voted_id])
current_user.vote!(@post)
respond_to do |format|
format.html { redirect_to @post }
format.js { render :action => "create_vote" }
end
elsif params[:thanked_id]
@post = Post.find(params[:appreciation][:thanked_id])
current_user.thank!(@post)
respond_to do |format|
format.html { redirect_to @post }
format.js {render :action => 'create_thank'}
end
end
end
def destroy
if params[:liked_id]
@post = Appreciation.find(params[:id]).liked
current_user.unlike!(@post)
respond_to do |format|
format.html { redirect_to @post }
format.js { render :action => "destroy_like" }
end
elsif params[:vote_id]
@post = Appreciation.find(params[:id]).voted
current_user.unvote!(@post)
respond_to do |format|
format.html { redirect_to @post }
format.js { render :action => "destroy_vote" }
end
elsif params[:thanked_id]
@post = Appreciation.find(params[:id]).thanked
current_user.unthank!(@post)
respond_to do |format|
format.html { redirect_to @post }
format.js { render :action => "destroy_thank" }
end
end
end
end
Your
paramscheck is incorrect;liked_idis nested within the:appreciationhash.