I'm still relatively new to rails and getting used to a few things. Just a quick question really, I have an AJAX form (with :remote => true etc...) which works and sends the data to the server without a pageload.
My question is around the javascript file that can be used after the post. My partial is called '_newsomething.html.erb' and once it's posted I want to execute a javascript file - do these files have to be named after actions in the controller to sync and work properly in rails? At the moment I have a javascript file called 'create.js.erb' with just an javascript alert in it, but it's not firing.
e.g. do I need to have a partial called '_create.html.erb' and then a javascript file called 'create.js.erb'? Is there anyway of telling Rails where to go for a javascript file from within the controller?
Thanks in advance!
EDIT: Controller code below (very basic and generated at the moment)
def create
@snip = Snip.new(params[:snip])
respond_to do |format|
if @snip.save
format.html { redirect_to(@snip, :notice => 'Snip was successfully created.') }
format.xml { render :xml => @snip, :status => :created, :location => @snip }
else
format.html { render :action => "new" }
format.xml { render :xml => @snip.errors, :status => :unprocessable_entity }
end
end
end