1

I'm trying to use the best_in_place gem but it doesn't seem to be working. I followed the railscast tutorial but now luck. When I say it doesn't work, I mean there is no option to edit anything on the screen. Appears in the default rails manner.

posts/show.html.erb

<p id="notice"><%= notice %></p>

<p>
  <b>
    <%= best_in_place @post, :title %>
  </b>
</p>

<p>
  <%= best_in_place @post ,:content, :type => :text_area %>
</p>

<p>
  <b>Featured:</b>
  <%= best_in_place @post , :featured, :type => :check_box %>
</p>


<%= link_to 'Edit', edit_post_path(@post) %> |
<%= link_to 'Back', posts_path %>

posts.js.coffee

# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

jQuery ->
  $('.best_in_place').best_in_place()

application.js

// This is a manifest file that'll be compiled into including all the files listed below.
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
// be included in the compiled file accessible from http://example.com/assets/application.js
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
//= require jquery
//= require jquery_ujs
//= require jquery.purr
//= require best_in_place
//= require_tree 

.

gemfile

source 'http://rubygems.org'

gem 'best_in_place'
gem 'rails', '3.1.3'

gem 'pg'
gem "paperclip"

group :assets do
  gem 'sass-rails',   '~> 3.1.5'
  gem 'coffee-rails', '~> 3.1.1'
  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

group :test do
  # Pretty printed test output
  gem 'turn', '0.8.2', :require => false
end
Antarr Byrd
  • 24,863
  • 33
  • 100
  • 188
  • See any Javascript errors in your browser? You may have to use Firebug or turn on Developer Tools in Chrome. – rkb Dec 24 '11 at 23:06
  • I just added best_in_place and like you noticed that there are no icons. Though when I actually clicked on the field it became editable. Turns out that I didn't have the CSS (maybe I missed a step). Check http://bipapp.heroku.com/users/45 for some example CSS you can use. It's a demo from the developers. – Adam21e Feb 16 '12 at 06:01

3 Answers3

1

Can you show us your posts_controller.rb? Make sure that it responds_to :json and more specifically make sure the Update action specifies respond_with_bip(@post) for json.

If nothing is showing then try setting a default value in your model post.rb as such:

before_create :default_values

  private

    def default_values
      self.post ||= "Write Post Here"
    end
railser
  • 453
  • 1
  • 5
  • 19
1

Delete: posts.js.coffee

Add this below your posts/show.html.erb code:

$(document).ready(function() {
  /* Activating Best In Place */
  jQuery(".best_in_place").best_in_place();
});
Bruno
  • 6,211
  • 16
  • 69
  • 104
1

I was looking for solution for similar trouble in Rails. I found some answer in Rails 3.1 Assets - Strange Serving in Development

That works for me fine.

Community
  • 1
  • 1
proboszcz
  • 11
  • 1