- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 authlogic 在 rails 中使用 admin_name 和密码构建身份验证系统。我收到以下错误:
Mysql::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') = '[admin_name]') LIMIT 1' at line 1: SELECT
admins
.* FROMadmins
WHERE (LOWER(admins
.) = '[admin_name]') LIMIT 1
这是 admin_session_controller.rb 中的代码...
def login
@admin_session = AdminSession.new(params[:admin_session])
if @admin_session.save
flash[:notice] = 'Successfuly logged in.'
redirect_to :controller => 'admins', :action => 'email_stats'
else
flash[:notice] = 'Trouble!!'
render :action => 'new'
end
end
我猜它不喜欢 params[:admin_session]
,但我真的不知道为什么。
erb 模板....
<%= render :partial => 'layouts/head_admins' %>
<div id="notice">
<% if flash[:notice] %>
<%= flash[:notice] %>
<% end %>
</div>
<div id="main" align="middle">
<table>
<%= form_for @admin_session, :as => :admin_session, :url => { :action => "login" } do |f| %>
<tr class="bold gray">Admin_name</tr>
<tr id="login_admin_name"><%= f.text_field :admin_name, :class => "text", :tabindex => "1" %></tr>
<tr class="bold gray">Password</tr>
<tr id="login_password"><%= f.password_field :password, :class => "password", :tabindex => "2" %></tr>
<tr><%= image_submit_tag("login_btn.png", :id => 'login_btn', :class=>"image", :tabindex => "3", :alt => 'Login') %></tr>
<tr class="gray"><%= f.check_box :remember_me %>Keep me logged in</tr>
<% end %>
</table>
</div>
这是错误日志:
Started POST "/admin_session/login" for 127.0.0.1 at 2011-07-17 19:58:07 -0700
Processing by AdminSessionController#login as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"[token]", "admin_session"=>{"admin_name"=>"[admin_name]", "password"=>"[FILTERED]"}, "x"=>"35", "y"=>"14"}
[1m[36mAdmin Load (136.4ms)[0m [1mSELECT `admins`.* FROM `admins` WHERE (LOWER(`admins`.) = '[admin_name]') LIMIT 1[0m
Mysql::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') = '[admin_name]') LIMIT 1' at line 1: SELECT `admins`.* FROM `admins` WHERE (LOWER(`admins`.) = '[admin_name]') LIMIT 1
Completed in 563ms
ActiveRecord::StatementInvalid (Mysql::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') = '[admin_name]') LIMIT 1' at line 1: SELECT `admins`.* FROM `admins` WHERE (LOWER(`admins`.) = '[admin_name]') LIMIT 1):
app/controllers/admin_session_controller.rb:18:in `login'
Rendered /home/tm/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.3/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.8ms)
Rendered /home/tm/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.3/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (6.7m
这是完整的轨迹......
activerecord (3.0.3) lib/active_record/connection_adapters/abstract_adapter.rb:202:in `rescue in log'
activerecord (3.0.3) lib/active_record/connection_adapters/abstract_adapter.rb:194:in `log'
activerecord (3.0.3) lib/active_record/connection_adapters/mysql_adapter.rb:289:in `execute'
activerecord (3.0.3) lib/active_record/connection_adapters/mysql_adapter.rb:619:in `select'
activerecord (3.0.3) lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `select_all'
activerecord (3.0.3) lib/active_record/connection_adapters/abstract/query_cache.rb:54:in `block in select_all'
activerecord (3.0.3) lib/active_record/connection_adapters/abstract/query_cache.rb:68:in `cache_sql'
activerecord (3.0.3) lib/active_record/connection_adapters/abstract/query_cache.rb:54:in `select_all'
activerecord (3.0.3) lib/active_record/base.rb:467:in `find_by_sql'
activerecord (3.0.3) lib/active_record/relation.rb:64:in `to_a'
activerecord (3.0.3) lib/active_record/relation/finder_methods.rb:333:in `find_first'
activerecord (3.0.3) lib/active_record/relation/finder_methods.rb:122:in `first'
activerecord (3.0.3) lib/active_record/relation/finder_methods.rb:119:in `first'
activerecord (3.0.3) lib/active_record/base.rb:439:in `first'
/home/tm/.rvm/gems/ruby-1.9.2-p180/bundler/gems/authlogic-a087ad0cba3c/lib/authlogic/acts_as_authentic/login.rb:121:in `find_with_case'
/home/tm/.rvm/gems/ruby-1.9.2-p180/bundler/gems/authlogic-a087ad0cba3c/lib/authlogic/acts_as_authentic/login.rb:112:in `find_by_smart_case_login_field'
/home/tm/.rvm/gems/ruby-1.9.2-p180/bundler/gems/authlogic-a087ad0cba3c/lib/authlogic/session/scopes.rb:95:in `block in search_for_record'
activerecord (3.0.3) lib/active_record/base.rb:1121:in `with_scope'
/home/tm/.rvm/gems/ruby-1.9.2-p180/bundler/gems/authlogic-a087ad0cba3c/lib/authlogic/session/scopes.rb:94:in `search_for_record'
/home/tm/.rvm/gems/ruby-1.9.2-p180/bundler/gems/authlogic-a087ad0cba3c/lib/authlogic/session/password.rb:183:in `validate_by_password'
activesupport (3.0.3) lib/active_support/callbacks.rb:415:in `_run_validate_callbacks'
activesupport (3.0.3) lib/active_support/callbacks.rb:93:in `run_callbacks'
/home/tm/.rvm/gems/ruby-1.9.2-p180/bundler/gems/authlogic-a087ad0cba3c/lib/authlogic/session/callbacks.rb:87:in `validate'
/home/tm/.rvm/gems/ruby-1.9.2-p180/bundler/gems/authlogic-a087ad0cba3c/lib/authlogic/session/validation.rb:64:in `valid?'
/home/tm/.rvm/gems/ruby-1.9.2-p180/bundler/gems/authlogic-a087ad0cba3c/lib/authlogic/session/existence.rb:65:in `save'
app/controllers/admin_session_controller.rb:19:in `login'
actionpack (3.0.3) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.0.3) lib/abstract_controller/base.rb:151:in `process_action'
actionpack (3.0.3) lib/action_controller/metal/rendering.rb:11:in `process_action'
actionpack (3.0.3) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.0.3) lib/active_support/callbacks.rb:445:in `_run__640502527__process_action__573632350__callbacks'
activesupport (3.0.3) lib/active_support/callbacks.rb:409:in `_run_process_action_callbacks'
activesupport (3.0.3) lib/active_support/callbacks.rb:93:in `run_callbacks'
actionpack (3.0.3) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.0.3) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.0.3) lib/active_support/notifications.rb:52:in `block in instrument'
activesupport (3.0.3) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.0.3) lib/active_support/notifications.rb:52:in `instrument'
actionpack (3.0.3) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.0.3) lib/action_controller/metal/rescue.rb:17:in `process_action'
actionpack (3.0.3) lib/abstract_controller/base.rb:120:in `process'
actionpack (3.0.3) lib/abstract_controller/rendering.rb:40:in `process'
actionpack (3.0.3) lib/action_controller/metal.rb:138:in `dispatch'
actionpack (3.0.3) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.0.3) lib/action_controller/metal.rb:178:in `block in action'
actionpack (3.0.3) lib/action_dispatch/routing/route_set.rb:62:in `call'
actionpack (3.0.3) lib/action_dispatch/routing/route_set.rb:62:in `dispatch'
actionpack (3.0.3) lib/action_dispatch/routing/route_set.rb:27:in `call'
rack-mount (0.6.13) lib/rack/mount/route_set.rb:148:in `block in call'
rack-mount (0.6.13) lib/rack/mount/code_generation.rb:93:in `block in recognize'
rack-mount (0.6.13) lib/rack/mount/code_generation.rb:68:in `optimized_each'
rack-mount (0.6.13) lib/rack/mount/code_generation.rb:92:in `recognize'
rack-mount (0.6.13) lib/rack/mount/route_set.rb:139:in `call'
actionpack (3.0.3) lib/action_dispatch/routing/route_set.rb:492:in `call'
actionpack (3.0.3) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
actionpack (3.0.3) lib/action_dispatch/middleware/head.rb:14:in `call'
rack (1.2.1) lib/rack/methodoverride.rb:24:in `call'
actionpack (3.0.3) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.0.3) lib/action_dispatch/middleware/flash.rb:182:in `call'
actionpack (3.0.3) lib/action_dispatch/middleware/session/abstract_store.rb:149:in `call'
actionpack (3.0.3) lib/action_dispatch/middleware/cookies.rb:295:in `call'
activerecord (3.0.3) lib/active_record/query_cache.rb:32:in `block in call'
activerecord (3.0.3) lib/active_record/connection_adapters/abstract/query_cache.rb:28:in `cache'
activerecord (3.0.3) lib/active_record/query_cache.rb:12:in `cache'
activerecord (3.0.3) lib/active_record/query_cache.rb:31:in `call'
activerecord (3.0.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:353:in `call'
actionpack (3.0.3) lib/action_dispatch/middleware/callbacks.rb:46:in `block in call'
activesupport (3.0.3) lib/active_support/callbacks.rb:415:in `_run_call_callbacks'
actionpack (3.0.3) lib/action_dispatch/middleware/callbacks.rb:44:in `call'
rack (1.2.1) lib/rack/sendfile.rb:107:in `call'
actionpack (3.0.3) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
actionpack (3.0.3) lib/action_dispatch/middleware/show_exceptions.rb:46:in `call'
railties (3.0.3) lib/rails/rack/logger.rb:13:in `call'
rack (1.2.1) lib/rack/runtime.rb:17:in `call'
activesupport (3.0.3) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.2.1) lib/rack/lock.rb:11:in `block in call'
<internal:prelude>:10:in `synchronize'
rack (1.2.1) lib/rack/lock.rb:11:in `call'
actionpack (3.0.3) lib/action_dispatch/middleware/static.rb:30:in `call'
railties (3.0.3) lib/rails/application.rb:168:in `call'
railties (3.0.3) lib/rails/application.rb:77:in `method_missing'
railties (3.0.3) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.2.1) lib/rack/content_length.rb:13:in `call'
rack (1.2.1) lib/rack/chunked.rb:15:in `call'
rack (1.2.1) lib/rack/handler/mongrel.rb:67:in `process'
mongrel (1.2.0.pre2) lib/mongrel.rb:165:in `block in process_client'
mongrel (1.2.0.pre2) lib/mongrel.rb:164:in `each'
mongrel (1.2.0.pre2) lib/mongrel.rb:164:in `process_client'
mongrel (1.2.0.pre2) lib/mongrel.rb:291:in `block (2 levels) in run'
谢谢...
最佳答案
我假设您并没有真正在文本字段中键入“[admin_name]”,而是调整了您向我们展示的日志?
您是在告诉 Authlogic 登录字段使用什么字段吗?除非它是默认值之一,否则这可能会解释为什么生成的 SQL 不包含要比较的实际列名...
SELECT `admins`.* FROM `admins` WHERE (LOWER(`admins`.) = '[admin_name]')
关于mysql - rails、authlogic 和 sql 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6728519/
我已经使用 vue-cli 两个星期了,直到今天一切正常。我在本地建立这个项目。 https://drive.google.com/open?id=0BwGw1zyyKjW7S3RYWXRaX24tQ
您好,我正在尝试使用 python 库 pytesseract 从图像中提取文本。请找到代码: from PIL import Image from pytesseract import image_
我的错误 /usr/bin/ld: errno: TLS definition in /lib/libc.so.6 section .tbss mismatches non-TLS reference
我已经训练了一个模型,我正在尝试使用 predict函数但它返回以下错误。 Error in contrasts<-(*tmp*, value = contr.funs[1 + isOF[nn]])
根据Microsoft DataConnectors的信息我想通过 this ODBC driver 创建一个从 PowerBi 到 PostgreSQL 的连接器使用直接查询。我重用了 Micros
我已经为 SoundManagement 创建了一个包,其中有一个扩展 MediaPlayer 的类。我希望全局控制这个变量。这是我的代码: package soundmanagement; impo
我在Heroku上部署了一个应用程序。我正在使用免费服务。 我经常收到以下错误消息。 PG::Error: ERROR: out of memory 如果刷新浏览器,就可以了。但是随后,它又随机发生
我正在运行 LAMP 服务器,这个 .htaccess 给我一个 500 错误。其作用是过滤关键字并重定向到相应的域名。 Options +FollowSymLinks RewriteEngine
我有两个驱动器 A 和 B。使用 python 脚本,我在“A”驱动器中创建一些文件,并运行 powerscript,该脚本以 1 秒的间隔将驱动器 A 中的所有文件复制到驱动器 B。 我在 powe
下面的函数一直返回这个错误信息。我认为可能是 double_precision 字段类型导致了这种情况,我尝试使用 CAST,但要么不是这样,要么我没有做对...帮助? 这是错误: ERROR: i
这个问题已经有答案了: Syntax error due to using a reserved word as a table or column name in MySQL (1 个回答) 已关闭
我的数据库有这个小问题。 我创建了一个表“articoli”,其中包含商品的品牌、型号和价格。 每篇文章都由一个 id (ID_ARTICOLO)` 定义,它是一个自动递增字段。 好吧,现在当我尝试插
我是新来的。我目前正在 DeVry 在线学习中级 C++ 编程。我们正在使用 C++ Primer Plus 这本书,到目前为止我一直做得很好。我的老师最近向我们扔了一个曲线球。我目前的任务是这样的:
这个问题在这里已经有了答案: What is an undefined reference/unresolved external symbol error and how do I fix it?
我的网站中有一段代码有问题;此错误仅发生在 Internet Explorer 7 中。 我没有在这里发布我所有的 HTML/CSS 标记,而是发布了网站的一个版本 here . 如您所见,我在列中有
如果尝试在 USB 设备上构建 node.js 应用程序时在我的树莓派上使用 npm 时遇到一些问题。 package.json 看起来像这样: { "name" : "node-todo",
在 Python 中,您有 None单例,在某些情况下表现得很奇怪: >>> a = None >>> type(a) >>> isinstance(a,None) Traceback (most
这是我的 build.gradle (Module:app) 文件: apply plugin: 'com.android.application' android { compileSdkV
我是 android 的新手,我的项目刚才编译和运行正常,但在我尝试实现抽屉导航后,它给了我这个错误 FAILURE: Build failed with an exception. What wen
谁能解释一下?我想我正在做一些非常愚蠢的事情,并且急切地等待着启蒙。 我得到这个输出: phpversion() == 7.2.25-1+0~20191128.32+debian8~1.gbp108
我是一名优秀的程序员,十分优秀!