jquery - remote: true Ajax call works in local server but not in Heroku -
this first question stack overflow.
i'm writing rails app running in heroku. user can / unlike posts. action registered recommendable gem's sidekiq workers.
i'm using public activity track activities of posts, hence a.trackable.id post.id...
i have ajax call in following code working in localhost :
public_activity/posts/_create.html.erb :
<%= link_to "beğenmekten vazgeç", unlike_post_path(a.trackable.id), data: {id: a.trackable.id, toggle_text: 'beğen', toggle_href: like_post_path(a.trackable.id)}, class: 'like_toggle', remote: true %> in posts controller :
def @post = post.find(params[:id]) current_user.like(@post) if request.xhr? render json: { id: @post.id } else redirect_to user_profile_path(@post.user) flash[:notice] = "ajax hatası" end end and _create.coffee file is
$(document).on 'ajax:success', 'a.like_toggle', (status, data, xhr) -> $("a.like_toggle[data-id=#{data.id}]").each -> $a = $(this) href = $a.attr 'href' text = $a.text() $a.text($a.data('toggle-text')).attr 'href', $a.data('toggle-href') $a.data('toggle-text', text).data 'toggle-href', href return essentially, changes / dislike text described in this question.
in gemfile, have
gem 'jquery-rails', '~> 4.0.3' and in application.js file have ;
//= require jquery //= require jquery_ujs //= require jquery-ui i cleaned , precompiled assets in production.
it working ok in localhost. in heroku, can't seem working.
here's server log :
processing postscontroller#like html parameters: {"id"=>"1"} user load (1.7ms) select "users".* "users" "users"."id" = $1 order "users"."id" asc limit 1 [["id", 1]] post load (1.6ms) select "posts".* "posts" "posts"."id" = $1 limit 1 [["id", 1]] redirected https://emoportal.herokuapp.com/user_profiles/1 2015-04-24t16:14:15.287z 3 tid-osdy24n1g recommendable::workers::sidekiq jid-986cd2fea4f7bfffd55849b0 info: start 2015-04-24t16:14:15.368z 3 tid-osdy24n1g recommendable::workers::sidekiq jid-986cd2fea4f7bfffd55849b0 info: done: 0.082 sec user load (1.3ms) select "users".* "users" "users"."id" = $1 limit 1 [["id", 1]] completed 302 found in 680ms (activerecord: 6.7ms) any or ideas appreciated. thanks.
solved it. problem jquery_ujs not present in heroku environment, despite precompilation , other stuff.
in config/environments/production.rb file, set config.serve_static_files = true , did rails_env=production rake assets:precompile pushed repo heroku.
that it.
Comments
Post a Comment