【发布时间】:2014-08-06 09:53:25
【问题描述】:
我创建了一个 user_controller,它基本上扩展了设计用户设置,使用以下语法:
class UsersController < ApplicationController
def index
@users = User.order('created_at DESC').all
end
def create
@user = User.create(user_params)
end
private
def user_params
params.permit :user (:avatar, :email, :password, :password_confirmation )
end
end
在我的模型 user.rb 我有:
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
has_attached_file :avatar, styles: {
large: "600x450#",
medium: "250x250#",
small: "100x100#"
}, :default_url => "/images/:style/filler.png"
#validates_attachment_content_type :avatar, :content_type => ["image/jpg", "image/jpeg", "image/png", "image/gif"]
validates_attachment_content_type :avatar, :content_type => /\Aimage\/.*\Z/
validates :avatar, :email, :password, presence: true
end
这些都可以正常工作,但是当我重新加载页面时,我收到一个奇怪的错误,说存在语法错误,而且很奇怪,因为它在此之前工作。我假设它在 Rails 版本中存在某种语法错误。
错误是:
Error details saved to: /tmp/passenger-error-9mVpXM.html
Message from application: /home/deployer/staging/releases/20140806094001/app/controllers/users_controller.rb:11: syntax error, unexpected ',', expecting ')'
...require(:user).permit (:avatar, :email, :password, :password...
... ^
/home/deployer/staging/releases/20140806094001/app/controllers/users_controller.rb:11: syntax error, unexpected ',', expecting :: or '[' or '.'
...it (:avatar, :email, :password, :password_confirmation )
... ^ (SyntaxError)
这有什么明显的错误吗?
【问题讨论】:
标签: ruby-on-rails ruby ruby-on-rails-4