Hi all, I am very very new to ruby and rails so I thought I''d follow a couple of starter manuals. Bellow the error I have listed versions and commands executed. The problem I am having is that I can display: http://acc.precognet.com/invoices/new but when I try to display: http://acc.precognet.com/invoices or http://acc.precognet.com/invoices/list I get the following error: NameError in InvoicesController#index uninitialized constant Invoice RAILS_ROOT: /var/www/acc.precognet.com/public/../config/.. Application Trace | Framework Trace | Full Trace /usr/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:266:in `load_missing_constant'' /usr/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:452:in `const_missing'' /usr/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:464:in `const_missing'' /usr/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/inflector.rb:250:in `constantize'' /usr/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/core_ext/string/inflections.rb:148:in `constantize'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_controller/pagination.rb:201:in `paginator_and_collection_for'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_controller/pagination.rb:132:in `paginate_without_deprecation'' /usr/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/deprecation.rb:94:in `paginate'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_controller/scaffolding.rb:108:in `list'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_controller/scaffolding.rb:96:in `index'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_controller/base.rb:1101:in `send'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_controller/base.rb:1101:in `perform_action_without_filters'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_controller/filters.rb:696:in `call_filters'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_controller/filters.rb:688:in `perform_action_without_benchmark'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_controller/benchmarking.rb:66:in `perform_action_without_rescue'' /usr/lib/ruby/1.8/benchmark.rb:293:in `measure'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_controller/benchmarking.rb:66:in `perform_action_without_rescue'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_controller/rescue.rb:83:in `perform_action'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_controller/base.rb:435:in `send'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_controller/base.rb:435:in `process_without_filters'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_controller/filters.rb:684:in `process_without_session_management_support'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_controller/session_management.rb:114:in `process'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_controller/base.rb:334:in `process'' /usr/lib/ruby/gems/1.8/gems/rails-1.2.5/lib/dispatcher.rb:41:in `dispatch'' /usr/lib/ruby/gems/1.8/gems/rails-1.2.5/lib/fcgi_handler.rb:168:in `process_request'' /usr/lib/ruby/gems/1.8/gems/rails-1.2.5/lib/fcgi_handler.rb:143:in `process_each_request!'' /usr/lib/ruby/gems/1.8/gems/rails-1.2.5/lib/fcgi_handler.rb:109:in `with_signal_handler'' /usr/lib/ruby/gems/1.8/gems/rails-1.2.5/lib/fcgi_handler.rb:142:in `process_each_request!'' /usr/lib/ruby/site_ruby/1.8/fcgi.rb:600:in `each_cgi'' /usr/lib/ruby/site_ruby/1.8/fcgi.rb:597:in `each'' /usr/lib/ruby/site_ruby/1.8/fcgi.rb:597:in `each_cgi'' /usr/lib/ruby/gems/1.8/gems/rails-1.2.5/lib/fcgi_handler.rb:141:in `process_each_request!'' /usr/lib/ruby/gems/1.8/gems/rails-1.2.5/lib/fcgi_handler.rb:55:in `process!'' /usr/lib/ruby/gems/1.8/gems/rails-1.2.5/lib/fcgi_handler.rb:25:in `process!'' /var/www/acc.precognet.com/public/dispatch.fcgi:24 Request Parameters: {"invoices.html"=>nil} Show session dump --- flash: !map:ActionController::Flash::FlashHash {} Response Headers: {"cookie"=>[], "Cache-Control"=>"no-cache"} I am using: Ruby version 1.8.6 (i686-linux) RubyGems version 0.9.4 Rails version 1.2.5 Active Record version 1.15.5 Action Pack version 1.13.5 Action Web Service version 1.2.5 Action Mailer version 1.3.5 Active Support version 1.4.4 Application root /var/www/acc.precognet.com Environment development Database adapter mysql Here are all the steps I took: # cd /var/www # rails acc.precognet.com # cd acc.precognet.com/config dev info from database.yml development: adapter: mysql database: dev_precognet username: dev password: password socket: /var/run/mysqld/mysqld.sock I took an existing db, dumped it to an sql file, renamed the db to dev_db and reinjected into mysql. # cat /etc/apache2/vhosts.d/acc.precognet.com.conf <pre> <VirtualHost *:80> SetEnv RAILS_ENV development ServerName acc.precognet.com DocumentRoot /var/www/acc.precognet.com/public ServerSignature On ErrorDocument 500 /500.html ErrorLog /var/log/apache2/acc.precognet.com.error_log CustomLog /var/log/apache2/acc.precognet.com.access_log combined LogLevel warn <Directory /var/www/acc.precognet.com/public/> Options ExecCGI FollowSymLinks AddHandler fcgid-script .fcgi Order allow,deny Allow from all RewriteEngine On RewriteRule ^$ index.html [QSA] RewriteRule ^([^.]+)$ $1.html [QSA] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ /dispatch.fcgi?$1 [QSA,L] AllowOverride None </Directory> </VirtualHost> </pre> # /etc/init.d/apache2 restart # cd /var/www/acc.precognet.com # ruby script/generate model invoices # ruby script/generate controler invoices # cat app/controllers/invoices_controller.rb class InvoicesController < ApplicationController scaffold :invoices end # chown -R apache:apache public tmp # vi public/dispatch.fcgi RailsFCGIHandler.process! ''/var/log/apache2/acc.precognet.com_fcgi_crash.log'' # touch /var/log/apache2/acc.precognet.com_fcgi_crash.log # chown apache:apache /var/log/apache2/acc.precognet.com_fcgi_crash.log Replace the following in public/.htaccess #RewriteRule ^(.*)$ dispatch.cgi [QSA,L] RewriteRule ^(.*)$ dispatch.fcgi [QSA,L] Relevant SQL table dump: -- -- Table structure for table `invoices` -- DROP TABLE IF EXISTS `invoices`; CREATE TABLE `invoices` ( `id` int(6) unsigned zerofill NOT NULL, `cli_id` int(8) unsigned zerofill NOT NULL, `sent` date NOT NULL, `amount` decimal(7,2) NOT NULL, `payed` date default NULL, `path` varchar(254) default NULL, `filename` varchar(15) default NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COMMENT=''Precognet invoices table''; I''m sorry for the long post but I have tried many times and never get past this step. I hope someone can help :) -Ed ------------------------------------------------------- --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
edoardo.costa-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Nov-17 23:57 UTC
Re: can''t list db content in rails
The following is something I have discovered although I can''t figure out why... My tables tend to end with an ''s'' such as clients but if I run the following commands without the ''s'' (single client) , then it works # ruby script/generate model client exists app/models/ exists test/unit/ exists test/fixtures/ create app/models/client.rb create test/unit/client_test.rb create test/fixtures/clients.yml create db/migrate create db/migrate/001_create_clients.rb # ruby script/generate controler client exists app/controllers/ exists app/helpers/ create app/views/client exists test/functional/ create app/controllers/client_controller.rb create test/functional/client_controller_test.rb create app/helpers/client_helper.rb http://acc.precognet.com/client Listing clients ... So even though I mention the wrong table name ''client'' rather than ''clients'', it works and the output says ''clients''!! Any thoughts on this? -Ed --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Ed Using Active Scaffold makes data manipulation and display pretty trival. CCH http://cch4rails.blogspot.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
edoardo.costa-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Nov-18 08:53 UTC
Re: can''t list db content in rails
Hi CCH, Could you be a bit more specific? The problem I had was for example: 1) table named clients model and build using the client*s* fails 2) table named client model and build using the client fails 3) table named clients model and build using the client succeeds Now I doubt very much that a requirement of rails is that all tables should end with an ''s'' and all reference to them should ''lose'' the ''s''... so what am I doing wrong? -Ed On Nov 18, 5:36 am, CCH <c...-Z/Eug3sLCsSPzdAsCNHSEg@public.gmane.org> wrote:> Hi Ed > > Using Active Scaffold makes data manipulation and display pretty > trival. > > CCHhttp://cch4rails.blogspot.com--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi CCH On Nov 18, 4:53 pm, "edoardo.co...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <edoardo.co...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi CCH, > Could you be a bit more specific?cch : What I meant was database web development is a breeze with Active Scaffold plugin installed.> > The problem I had was for example: > > 1) table named clients > model and build using the client*s* fails > > 2) table named client > model and build using the client fails > > 3) table named clients > model and build using the client succeeds > > Now I doubt very much that a requirement of rails is that all tables > should end with an ''s'' and all reference to them should ''lose'' the > ''s''... so what am I doing wrong?cch: Yes, it is a Rails convention that all tables should end with an ''s'' unless you turn pluralization off. CCH http://cch4rails.blogspot.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
edoardo.costa-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Nov-18 11:09 UTC
Re: can''t list db content in rails
On Nov 18, 10:42 am, CCH <c...-Z/Eug3sLCsSPzdAsCNHSEg@public.gmane.org> wrote: ...> cch: Yes, it is a Rails convention that all tables should end with an > ''s'' unless you turn pluralization off. > > CCHhttp://cch4rails.blogspot.comHmmm, yes, just read about that. Odd but I guess taht with time I''ll understand why. Thanks for your input, I am one step further in the learning curve :) -Ed --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Well, thats not completely true. Tables should be plural (but not necessarily with an s) and your models should be singular. It''s just a conventions so that rails knows what table to look for, plus it makes sense. Take the example of a table holding people''s information. The table would be called people and the model would be person. This makes sense since because there are multiple people in the table so the table''s name rightly is "people". When you pull a record from that table and instantiate an object of your Person class, the singular name "Person" then makes sense because it represents one person from a table of people. Hope this clears it up a bit, -Bill edoardo.costa-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> On Nov 18, 10:42 am, CCH <c...-Z/Eug3sLCsSPzdAsCNHSEg@public.gmane.org> wrote: > ... > >> cch: Yes, it is a Rails convention that all tables should end with an >> ''s'' unless you turn pluralization off. >> >> CCHhttp://cch4rails.blogspot.com >> > > Hmmm, yes, just read about that. Odd but I guess taht with time I''ll > understand why. > > Thanks for your input, I am one step further in the learning curve :) > -Ed > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---