I followed Ryan Bates’ railscast on the best in place gem but cannot get it to work properly. The default value I set before_create in the user.rb model is showing up on the page but I cannot click on it to edit; it’s just showing as a static element. Although, Firebug is showing that the best_in_place javascript is being loaded in the view <head>.
application.js
//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require jquery-ui
//= require jquery.purr
//= require best_in_place
//= require_tree .
users.js.coffee
jQuery ->
$('.best_in_place').best_in_place()
user.rb
attr_accessible :email, :name, :password, :password_confirmation, :avatar, :goal
...
before_create :default_values
...
private
def default_values
self.goal ||= "Write Current Goal Here"
end
users_controller.rb
respond_to :html, :json
...
def update
@user = User.find(params[:id])
respond_to do |format|
if @user.update_attributes(params[:user])
format.html {
flash[:success] = "Profile updated"
sign_in @user
redirect_to @user
}
format.json { respond_with_bip(@user) }
else
format.html { render 'edit' }
format.json { respond_with_bip(@user) }
end
end
end
users/show.html.erb
...
<%= best_in_place @user, :goal %>
In your layouts/application.html.erb .. instead of
javascript_include_tag(:all)doAlso, make sure that
users.js.coffeelives inapp/assets/javascriptEdit
Ensure that you have the gem specified in the Gemfile and bundle installed
Try this, like Said Kaldybaev suggested
then instead of coffee do this at the top of the page:
If that doesn’t work, remove
//= require best_in_placeand//= require jquery.purrthen run