0
votes

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();
});
1
The text box appears when you click on the name ? If yes, what's in the console after you edit the name ?Baldrick
No nothing appears. Its like I dont even have best in place installed? It does nohing. Just displays the name like its hard coded!pratski
If best_in_place was not installed, you'll have an error during the view rendering on <%= best_in_place ... %>. It's certainly a javascript problem. You should check that there is no javascript error at page loading, that the best_in_place javascript file is present, and maybe debug to find what's wrong :-/Baldrick
Figured it out. Another JS file using an older version of jquery is clashing with this one. It works fine when I dont inlcude the old one. Thanks!!pratski
@pratski: please add the answer yourself and then accept that.berkes

1 Answers

0
votes

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.