I have a view folder that contains many js.coffee files that are called when various controller actions are executed. It is called when a remote form is submitted and is triggered in the controller by the respond_with line. I'm giving the create method as an example. It's important to note that all of this works PERFECTLY in development mode. In production, I've made sure I've precompiled my assets, ran bundle install --deployment etc.
users_controller.rb
def create
@user = User.new(params[:user])
if @user.save
respond_with @user, :location => users_url #This line is throwing the error in production
end
end
The following Jquery should be executed after the the record is saved and does so perfectly in development mode. It is important to note that the record is created, however the following file is never executed
create.js.coffee
$('#errors').empty()
$('#errors').show()
<% if @user.errors.any? %>
$('<%= escape_javascript(render :partial => "errors", :locals => {:target => @user })%>')
.appendTo('#errors')
<% else %>
$('<%= escape_javascript(render(:partial => @user))%>')
.appendTo('#user_table')
.hide()
.fadeIn(200)
$('#errors').hide()
$('#new_user')[0].reset()
$('#users_count').html '<%= users_count %>'
<% end %>
$('#error_close').click ->
$('#errors').fadeOut()
This is the error that is being thrown in production.
ActionView::MissingTemplate (Missing template users/create, application/create with {:locale=>[:en], :formats=>[:js, :html], :handlers=>[:erb, :builder]}. Searched in:
* "/home/ctilley/Development/RatatouilleCatering/app/views"
* "/home/ctilley/Development/RatatouilleCatering/vendor/bundle/ruby/1.9.1/gems/wash_out-0.3.1/app/views"
* "/home/ctilley/Development/RatatouilleCatering/vendor/bundle/ruby/1.9.1/gems/ckeditor-3.7.0.rc2/app/views"
):
app/controllers/users_controller.rb:19:in `create'