[Ror-es] Palabras reservadas en campos de bases de datos
Jaime Iniesta
Tue Feb 21 14:01:42 GMT 2006
Hola, me he enfrentado a un pequeño problema que no se bien a qué se
debe. Haciendo una pequeña aplicación web en la que tengo una lista de
páginas con su URL, título y descripción, monté en principio una tabla
"urls" con estos campos:
* id
* url
* title
* description
Al generar el scaffold para esto (ruby script/generate scaffold Url)
me lo crea sin problemas. Me meto por localhost:3000/urls y me aparece
el listado vacío, y al darle a "new url"... patapum! Me sale un fallo
que dice algo así como lo que anexo al final.
Pero si a la tabla la llamo "pages" y tiene estos campos:
* id
* address (en lugar de url)
* title
* description
Ya todo funciona como de costumbre. ¿Dónde estaba el fallo? ¿Quizá
"url" es una palabra reservada? ¿O está en que usé el nombre del
modelo, url, en un atributo del mismo?
#################
NoMethodError in Urls#new
Showing app/views/urls/new.rhtml where line #3 raised:
undefined method `rewrite' for #<Url:0xb7a68834>
Extracted source (around line #3):
1: <h1>New url</h1>
2:
3: <%= start_form_tag :action => 'create' %>
4: <%= render :partial => 'form' %>
5: <%= submit_tag "Create" %>
6: <%= end_form_tag %>
RAILS_ROOT: script/../config/..
Application Trace | Framework Trace | Full Trace
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.0/lib/active_record/base.rb:1497:in
`method_missing'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/base.rb:444:in
`url_for'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_view/helpers/url_helper.rb:18:in
`url_for'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_view/helpers/form_tag_helper.rb:26:in
`start_form_tag'
#{RAILS_ROOT}/app/views/urls/new.rhtml:3
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.0/lib/active_record/base.rb:1497:in
`method_missing'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/base.rb:444:in
`url_for'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_view/helpers/url_helper.rb:18:in
`url_for'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_view/helpers/form_tag_helper.rb:26:in
`start_form_tag'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_view/base.rb:269:in
`compile_and_render_template'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_view/base.rb:245:in
`render_template'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_view/base.rb:206:in
`render_file'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/base.rb:643:in
`render_file'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/base.rb:583:in
`render_with_no_layout'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/layout.rb:218:in
`render_without_benchmark'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/benchmarking.rb:53:in
`render'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/benchmarking.rb:53:in
`measure'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/benchmarking.rb:53:in
`render'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/base.rb:842:in
`perform_action_without_filters'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/filters.rb:332:in
`perform_action_without_benchmark'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/benchmarking.rb:69:in
`measure'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/rescue.rb:82:in
`perform_action'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/base.rb:365:in
`process_without_session_management_support'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/session_management.rb:116:in
`process'
/usr/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/dispatcher.rb:38:in `dispatch'
/usr/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/webrick_server.rb:117:in
`handle_dispatch'
/usr/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/webrick_server.rb:83:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:172:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:161:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:161:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
/usr/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/webrick_server.rb:69:in `dispatch'
/usr/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/commands/servers/webrick.rb:59
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'
/usr/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/dependencies.rb:214:in
`require'
/usr/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/commands/server.rb:28
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'
/usr/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/dependencies.rb:214:in
`require'
script/server:3
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.0/lib/active_record/base.rb:1497:in
`method_missing'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/base.rb:444:in
`url_for'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_view/helpers/url_helper.rb:18:in
`url_for'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_view/helpers/form_tag_helper.rb:26:in
`start_form_tag'
#{RAILS_ROOT}/app/views/urls/new.rhtml:3
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_view/base.rb:269:in
`compile_and_render_template'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_view/base.rb:245:in
`render_template'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_view/base.rb:206:in
`render_file'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/base.rb:643:in
`render_file'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/base.rb:583:in
`render_with_no_layout'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/layout.rb:218:in
`render_without_benchmark'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/benchmarking.rb:53:in
`render'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/benchmarking.rb:53:in
`measure'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/benchmarking.rb:53:in
`render'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/base.rb:842:in
`perform_action_without_filters'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/filters.rb:332:in
`perform_action_without_benchmark'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/benchmarking.rb:69:in
`measure'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/rescue.rb:82:in
`perform_action'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/base.rb:365:in
`process_without_session_management_support'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/session_management.rb:116:in
`process'
/usr/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/dispatcher.rb:38:in `dispatch'
/usr/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/webrick_server.rb:117:in
`handle_dispatch'
/usr/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/webrick_server.rb:83:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:172:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:161:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:161:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
/usr/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/webrick_server.rb:69:in `dispatch'
/usr/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/commands/servers/webrick.rb:59
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'
/usr/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/dependencies.rb:214:in
`require'
/usr/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/commands/server.rb:28
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'
/usr/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/dependencies.rb:214:in
`require'
script/server:3
Request
Parameters: None
--
Jaime Iniesta alias Capitán planeta
email: capitanplaneta ARROBA gmail PUNTO com
jabber: capitanplaneta ARROBA jabberes PUNTO org
http://capitanplaneta.blogspot.com/
http://railes.net