2015-06-13 4 views
2

я все шаги в соответствии с http://railscasts.com/episodes/302-in-place-editing?view=asciicastIn Place редактирования

но не редактирование на месте атрибутов?

Это моя страница

<div class="well-lg box-left box-first"> 
    <div class="row"> 
    <h3>Personal Details</h3> 
    <br> 
    <ul class="list-group"> 
    <li><strong><div class="col-sm-4">FName </div></strong> 
     <%= best_in_place @user, :fname %></li> 
    <li><strong><div class="col-sm-4">LName </div></strong> 
     <%= best_in_place @user, :lname %></li> 
    <li><strong><div class="col-sm-4">Email </div></strong> 
     <%= best_in_place @user, :email %></li> 
    <li><strong><div class="col-sm-4">Mobile </div></strong> 
     <%= best_in_place @user, :mob %></li> 
    </ul><br><%= link_to 'Edit', {:controller=>'users', :action=>'edit'}%> 
    </div> 
</div> 

Любая помощь или решение ?? Заранее спасибо

Редактировать

application.js

//= require jquery 
//= require jquery_ujs 
//= require jquery.purr 
//= require best_in_place 
//= require turbolinks 
//= require_tree . 

user.js.coffee

jQuery -> 
$('.best_in_place').best_in_place(); 
+0

Вы настроили код jQuery? '$ ('. best_in_place'). best_in_place()' –

+0

yes i did @Aakash – Peace

+0

Вы правильно настроили свои маршруты? – bhanu

ответ

0

Это не достаточно, чтобы поставить только помощник в HTML

вам нужно иметь правильный код в контроллере, а

код контроллера должен выглядят так (ответы json)

def update 
    @user = User.find params[:id] 

    respond_to do |format| 
    if @user.update_attributes(params[:user]) 
     format.html { redirect_to(@user, :notice => 'User was successfully updated.') } 
     format.json { respond_with_bip(@user) } 
    else 
     format.html { render :action => "edit" } 
     format.json { respond_with_bip(@user) } 
    end 
    end 
end 

, как и для помощника, не уверен, если он делает это по умолчанию, попробуйте добавить as: :input

посмотреть здесь https://github.com/bernat/best_in_place

+0

все еще не работает @Nick – Peace

0

Хотя, все понятно и шаг за шагом в documentation, но согласно вашему запросу, после это путь, я использую его:

application.js

//= require jquery-editable 

application.css

*= require jquery-editable 

Просмотреть

<a href="javscript:void(0)" id="some_id"> 

JavaScript

jQuery.fn.editable.defaults.mode = 'inline'; 
jQuery.fn.editable.defaults.ajaxOptions = {type: "PUT"}; 

jQuery("#some_id").editable({ 
    type: "text", 
    pk: "1", //This is id of the record which will be updated 
    url: url //The rails URL for controller method 
}); 

Тем не менее, я рекомендую вам пройти через документации для лучшего понимания и более гладкой реализации.