小编Ven*_*oad的帖子

当我尝试使用user.save时,为什么我的rails会回滚?

我已经安装了RailsTutorial示例应用程序(类似应用程序的推特),并且我试图理解为什么当我尝试更新用户数据库时,下面的控制台代码不会更新数据库.我期待用户信息在我使用后得到更新user.save.但是,这会回滚到未经编辑的数据.这是由于基于用户的限制吗?

用户控制器:

class UsersController < ApplicationController

#before_filter :signed_in_user, only: [:index, :edit, :update, :destroy, :following, :followers]
# By default before filters apply to all actions
#before_filter :correct_user, only: [:edit, :update]
  def edit
    @user = User.find(params[:id])
  end

  def update

    @user = User.find params[:id]

    respond_to do |format|

    if @user.update_attributes(params[:user])
      flash[:notice] = "Profile updated"
      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 …
Run Code Online (Sandbox Code Playgroud)

ruby ruby-on-rails railstutorial.org

50
推荐指数
5
解决办法
5万
查看次数

自制安装卡在make install上.我该如何解决?

我正在尝试安装imagemagick使用homebrew:

sudo brew install imagemagick
Run Code Online (Sandbox Code Playgroud)

它陷入了困境:

==> ./configure --prefix=/usr/local/Cellar/libtool/2.4.2 --program-prefix=g --en
==> make install
Run Code Online (Sandbox Code Playgroud)

我该如何调试?我如何安装imagemagick?

homebrew imagemagick

5
推荐指数
1
解决办法
1657
查看次数