I am trying to implement the best_in_place in my rails app and I cannot figure out how to implement it. It just doesnt do anything when I scroll over the text that needs to be edited. I have a nested profile model under Users and I want to edit the Users name. But the name is under the Profile Model. So I have "user.profile.name". I have folowed the installation steps and included and installed the gem and included the jquery files in my application.js as mentioned!
Here is my show view:
<%= best_in_place @profile, :name, :type => :input, :path => user_profile_path(@user) %>
Here is my show action in Users controller:
def show
@user = User.find_by_identifier!(params[:id])
@profile = @user.profile
end
Here is my Profiles controller:
respond_to :html, :json
def edit
@user = User.find_by_identifier!(params[:user_id])
@profile = @user.profile
end
def update
@user = User.find_by_identifier!(params[:user_id])
@profile = @user.profile
@profile.update_attributes(params[:profile])
respond_with @user
end
This is my application.js file
//= require jquery
//= require jquery_ujs
//= require best_in_place
//= require best_in_place.purr
//= require_tree .
$(document).ready(function() {
/* Activating Best In Place */
jQuery(".best_in_place").best_in_place();
});
Figured it out thanks to @baldrick. I had another jQuery plugin which was using an older version of jQuery. I removed the JS related to that plugin and Best_in_Place worked fine after that. The only problem is that I have to use one or the other since they are clashing or find out a way for the other plugin to work with a newer version of jQuery because some of the features are not supported by the newer version.