Asset Pipeline
Firstly, you need to make sure that you don't use any Rails dynamic path helpers in your javascript directly.
The issue is that if you pre-compile your asset pipeline, you'll typically find these dynamic path helpers won't work correctly. Although there's nothing "wrong" with it - I tend to keep Rails back-end code completely separate from the front-end, as to ensure the versatility of the application:
#app/assets/javascripts/application.js
$(document).on("click", ".element", function(){
$.ajax({
type: "GET",
url: "/cookbooks"
});
});
This will send a "naked" Ajax request (no params / body) to your controller backend:
#app/controllers/cookbooks_controller.rb
Class CookbooksController < ApplicationController
def index
@cookbooks = Cookbook.all
respond_to do |format|
format.html
format.js #-> loads /views/cookbooks/index.js.erb
end
end
end
The trick here is that you can now populate your index.js.erb
file with the params necessary to render the partial:
#app/views/cookbooks/index.js.erb
$("#property").html("<%=j render :partial => 'recipes/package_form' %>")
--
This should work for you