Использование gem best_in_place - PullRequest
1 голос
/ 14 декабря 2011

Я пытаюсь использовать гем best_in_place, но, похоже, он не работает. Я следовал руководству Railscast, но теперь удачи. Когда я говорю, что это не работает, я имею в виду, что нет возможности редактировать что-либо на экране. Появляется в стиле рельсов по умолчанию.

сообщений / 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

Ответы [ 3 ]

1 голос
/ 17 июля 2012

Можете ли вы показать нам свой posts_controller.rb?Убедитесь, что он Responds_to: json, а точнее, убедитесь, что в действии «Обновление» указано response_with_bip (@post) для json.

Если ничего не отображается, попробуйте установить значение по умолчанию в вашей модели post.rb следующим образом:

before_create :default_values

  private

    def default_values
      self.post ||= "Write Post Here"
    end
1 голос
/ 04 сентября 2013

Удалить: posts.js.coffee

Добавьте это под своим posts/show.html.erb кодом:

$(document).ready(function() {
  /* Activating Best In Place */
  jQuery(".best_in_place").best_in_place();
});
1 голос
/ 17 февраля 2012

Я искал решение для подобных проблем в Rails.Я нашел какой-то ответ в Rails 3.1 Активы - странное обслуживание в разработке

Это прекрасно работает для меня.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...