I was creating an acp for my ruby app, but when i ran:
ruby script\generate scaffold ‘acp/user’ username:string hashed_password:string password_salt:string joined:datetime last_visit:datetime business_name:string given_name:string family_name:string date_of_birth:date gender:bool country:string address:string address_2:string city:string state_or_region:string zip_code:string home_phone_number:string mobile_phone_number:string email:string jabber:string aim:string icq:string msn:string yim:string secret_question:string secret_awnser:string website:string occupation:string
I got this output:
create app/models/acp
create app/controllers/acp
create app/helpers/acp
create app/views/acp/users
create app/views/layouts/acp
create test/functional/acp
create test/unit/acp
create app/views/acp/users/index.html.erb
create app/views/acp/users/show.html.erb
create app/views/acp/users/new.html.erb
create app/views/acp/users/edit.html.erb
create app/views/layouts/acp/users.html.erb
create public/stylesheets/scaffold.css
dependency model
exists app/models/acp
exists test/unit/acp
create test/fixtures/acp
create app/models/acp/user.rb
create test/unit/acp/user_test.rb
create test/fixtures/acp_users.yml
create db/migrate
create db/migrate/001_create_acp_users.rb
create app/controllers/acp/users_controller.rb
create test/functional/acp/users_controller_test.rb
create app/helpers/acp/users_helper.rb
route map.resources :users
and: rake db:migrate
== 1 CreateAcpUsers: migrating
– create_table(:acp_users)
-> 0.2810s
== 1 CreateAcpUsers: migrated (0.2970s)
so now i had the users controller at /acp/users, and an acp_users db
table.
so why is it that when i access /acp/users I get an error saying that
the users table doesn’t exist? It isn’t supposed to either since it’s
named acp_users. How do I fix this? If you need anything else just
ask…
rails_root/acp/users_controller source:
class Acp::UsersController < ApplicationController
GET /acp_users
GET /acp_users.xml
def index
@acp_users = Acp::User.find(:all)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @acp_users }
end
end
GET /acp_users/1
GET /acp_users/1.xml
def show
@user = Acp::User.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @user }
end
end
GET /acp_users/new
GET /acp_users/new.xml
def new
@user = Acp::User.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @user }
end
end
GET /acp_users/1/edit
def edit
@user = Acp::User.find(params[:id])
end
POST /acp_users
POST /acp_users.xml
def create
@user = Acp::User.new(params[:user])
respond_to do |format|
if @user.save
flash[:notice] = 'Acp::User was successfully created.'
format.html { redirect_to(@user) }
format.xml { render :xml => @user, :status => :created,
:location => @user }
else
format.html { render :action => “new” }
format.xml { render :xml => @user.errors, :status =>
:unprocessable_entity }
end
end
end
PUT /acp_users/1
PUT /acp_users/1.xml
def update
@user = Acp::User.find(params[:id])
respond_to do |format|
if @user.update_attributes(params[:user])
flash[:notice] = 'Acp::User was successfully updated.'
format.html { redirect_to(@user) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @user.errors, :status =>
:unprocessable_entity }
end
end
end
DELETE /acp_users/1
DELETE /acp_users/1.xml
def destroy
@user = Acp::User.find(params[:id])
@user.destroy
respond_to do |format|
format.html { redirect_to(acp_users_url) }
format.xml { head :ok }
end
end
end
The error in detail:
ActiveRecord::StatementInvalid in Acp/usersController#index
Mysql::Error: #42S02Table ‘dc_development.users’ doesn’t exist: SELECT *
FROM users
RAILS_ROOT: D:/Documents and Settings/Matias
Vuori/Skrivbord/Work/.subversion/DeviousConcepts/trunk/DeviousConcepts.com/.httpd_root
Application Trace | Framework Trace | Full Trace
D:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract_adapter.rb:150:in
log' D:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/mysql_adapter.rb:281:in
execute’
D:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/mysql_adapter.rb:481:in
select' D:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in
select_all_without_query_cache’
D:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/query_cache.rb:53:in
select_all' D:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/query_cache.rb:74:in
cache_sql’
D:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/query_cache.rb:53:in
select_all' D:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:532:in
find_by_sql’
D:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:1233:in
find_every' D:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:503:in
find’
app/controllers/acp/users_controller.rb:5:in index' D:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:1158:in
send’
D:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:1158:in
perform_action_without_filters' D:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:697:in
call_filters’
D:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:689:in
perform_action_without_benchmark' D:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:68:in
perform_action_without_rescue’
D:/Ruby/lib/ruby/1.8/benchmark.rb:293:in measure' D:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:68:in
perform_action_without_rescue’
D:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/rescue.rb:199:in
perform_action_without_caching' D:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/caching.rb:678:in
perform_action’
D:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/query_cache.rb:33:in
cache' D:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/query_cache.rb:8:in
cache’
D:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/caching.rb:677:in
perform_action' D:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:524:in
send’
D:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:524:in
process_without_filters' D:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:685:in
process_without_session_management_support’
D:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/session_management.rb:123:in
process' D:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:388:in
process’
D:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:171:in
handle_request' D:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:115:in
dispatch’
D:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:126:in
dispatch_cgi' D:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:9:in
dispatch’
D:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86-mswin32/lib/mongrel/rails.rb:76:in
process' D:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86-mswin32/lib/mongrel/rails.rb:74:in
synchronize’
D:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86-mswin32/lib/mongrel/rails.rb:74:in
process' D:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86-mswin32/lib/mongrel.rb:159:in
process_client’
D:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86-mswin32/lib/mongrel.rb:158:in
each' D:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86-mswin32/lib/mongrel.rb:158:in
process_client’
D:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86-mswin32/lib/mongrel.rb:285:in
run' D:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86-mswin32/lib/mongrel.rb:285:in
initialize’
D:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86-mswin32/lib/mongrel.rb:285:in
new' D:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86-mswin32/lib/mongrel.rb:285:in
run’
D:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86-mswin32/lib/mongrel.rb:268:in
initialize' D:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86-mswin32/lib/mongrel.rb:268:in
new’
D:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86-mswin32/lib/mongrel.rb:268:in
run' D:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86-mswin32/lib/mongrel/configurator.rb:282:in
run’
D:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86-mswin32/lib/mongrel/configurator.rb:281:in
each' D:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86-mswin32/lib/mongrel/configurator.rb:281:in
run’
D:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86-mswin32/bin/mongrel_rails:128:in
run' D:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86-mswin32/lib/mongrel/command.rb:212:in
run’
D:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86-mswin32/bin/mongrel_rails:281
D:/Ruby/bin/mongrel_rails:19:in `load’
D:/Ruby/bin/mongrel_rails:19
Request
Parameters:
None
Show session dump
Response
Headers:
{“cookie”=>[],
“Cache-Control”=>“no-cache”}