0
我想在我的Rails应用中实现best_in_place,我无法弄清楚如何实现它。当我滚动需要编辑的文本时,它不会做任何事情。我在用户下有一个嵌套的配置文件模型,我想编辑用户名。但名字在Profile Model下。所以我有“user.profile.name”。我已经介绍了安装步骤,并包含并安装了gem,并在我的application.js中包含了jquery文件,如前所述!Rails Best_in_place编辑问题
这里是我的节目的看法:
<%= best_in_place @profile, :name, :type => :input, :path => user_profile_path(@user) %>
这里是我的节目在用户控制器动作:
def show
@user = User.find_by_identifier!(params[:id])
@profile = @user.profile
end
这里是我的配置控制器:
的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
这是我的application.js文件
//= 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();
});
单击名称时出现文本框?如果是,编辑名称后控制台中有什么? – Baldrick
不出现任何内容。它就像我甚至没有安装最好的地方?它做nohing。只需显示名称就像它的硬编码! – pratski
如果未安装best_in_place,则在视图呈现在<%= best_in_place ...%>'的过程中会出现错误。这当然是一个JavaScript问题。你应该检查页面加载时是否存在javascript错误,best_in_place javascript文件存在,并且可能需要调试才能找到问题所在: -/ – Baldrick