I''m new to Ruby and Rails, and I''m not sure which is most responsible for my confusion here. :) I have a minor legacy db issue: something that should be an int(3) is a char(3) instead. And it needs to be increased by an offset number to match other records. In PHP, this was fairly trivial, but in RoR, I''m having a frustrating time with it. First, I tried this: def project_no @project_num = project_num.to_i + 10 someMethod (project_num) end But this doesn''t work. someMethod always thinks that project_num is just 10 (ie, to_i converted project_num to 0). So I tried this: def project_no score = project_num.to_i score += 10 @project_num = score someMethod = project_num end And that worked. But it''s slightly ugly. And I, ultimately, I really want something more like: def update_project_no @project_num + 10 end def project_no @update_project_no someMethod (project_num) end Can anybody straighten me out here? I''d be much obliged. -- joshua --- Geek out: www.thewehners.net/joshua/
Can anybody help me decipher this error from apache.log? I''ve scoured the lists/google for more info on this but I''m officially stumped. The details: - suse 9.2/apache2/ruby 1.8.2/gem 0.8.10 - When I run gem list everything looks fine - The rails "congrats" screen works fine at localhost - But when I try install hieraki (for example) all I get on the frontend is "Application Error (Apache)" This is a snippet of what I get in apache.log: [Fri Apr 08 13:51:52 2005] [error] [client 127.0.0.1] /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:194:in `report_activate_error'' [Fri Apr 08 13:51:52 2005] [error] [client 127.0.0.1] : [Fri Apr 08 13:51:52 2005] [error] [client 127.0.0.1] Could not find RubyGem syntax (> 0.0.0) [Fri Apr 08 13:51:52 2005] [error] [client 127.0.0.1] ( [Fri Apr 08 13:51:52 2005] [error] [client 127.0.0.1] Gem::LoadError [Fri Apr 08 13:51:52 2005] [error] [client 127.0.0.1] ) [Fri Apr 08 13:51:52 2005] [error] [client 127.0.0.1] \tfrom /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:136:in `activate'' [Fri Apr 08 13:51:52 2005] [error] [client 127.0.0.1] \tfrom /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:37:in `require_gem_with_options'' [Fri Apr 08 13:51:52 2005] [error] [client 127.0.0.1] \tfrom /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:31:in `require_gem'' [Fri Apr 08 13:51:52 2005] [error] [client 127.0.0.1] \tfrom /srv/www/mycms/public/../config/environment.rb:42 [Fri Apr 08 13:51:52 2005] [error] [client 127.0.0.1] \tfrom /srv/www/mycms/public/dispatch.cgi:3:in `require'' [Fri Apr 08 13:51:52 2005] [error] [client 127.0.0.1] \tfrom /srv/www/mycms/public/dispatch.cgi:3 [Fri Apr 08 13:51:52 2005] [error] [client 127.0.0.1] Premature end of script headers: dispatch.cgi I have double checked permissions and tried looking into the report_activate_error function in rubygems.rb - it seems like there is some sort of version conflict somewhere? It seems to me I have the latest of everything in the right locations. Thanks, Tim
On Apr 8, 2005 3:06 PM, Tim Broeker <tim-lmTtMILVy1gjk9F/YNdkvQ@public.gmane.org> wrote:> Can anybody help me decipher this error from apache.log? I''ve scoured > the lists/google for more info on this but I''m officially stumped. The > details: > > - suse 9.2/apache2/ruby 1.8.2/gem 0.8.10 > > - When I run gem list everything looks fine > > - The rails "congrats" screen works fine at localhost > > - But when I try install hieraki (for example) all I get on the frontend > is "Application Error (Apache)" > > This is a snippet of what I get in apache.log: > > [Fri Apr 08 13:51:52 2005] [error] [client 127.0.0.1] > /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:194:in `report_activate_error'' > [Fri Apr 08 13:51:52 2005] [error] [client 127.0.0.1] : > [Fri Apr 08 13:51:52 2005] [error] [client 127.0.0.1] Could not find > RubyGem syntax (> 0.0.0) > [Fri Apr 08 13:51:52 2005] [error] [client 127.0.0.1] ( > [Fri Apr 08 13:51:52 2005] [error] [client 127.0.0.1] Gem::LoadError > [Fri Apr 08 13:51:52 2005] [error] [client 127.0.0.1] ) > [Fri Apr 08 13:51:52 2005] [error] [client 127.0.0.1] \tfrom > /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:136:in `activate'' > [Fri Apr 08 13:51:52 2005] [error] [client 127.0.0.1] \tfrom > /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:37:in > `require_gem_with_options'' > [Fri Apr 08 13:51:52 2005] [error] [client 127.0.0.1] \tfrom > /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:31:in `require_gem'' > [Fri Apr 08 13:51:52 2005] [error] [client 127.0.0.1] \tfrom > /srv/www/mycms/public/../config/environment.rb:42 > [Fri Apr 08 13:51:52 2005] [error] [client 127.0.0.1] \tfrom > /srv/www/mycms/public/dispatch.cgi:3:in `require'' > [Fri Apr 08 13:51:52 2005] [error] [client 127.0.0.1] \tfrom > /srv/www/mycms/public/dispatch.cgi:3 > [Fri Apr 08 13:51:52 2005] [error] [client 127.0.0.1] Premature end of > script headers: dispatch.cgi > > I have double checked permissions and tried looking into the > report_activate_error function in rubygems.rb - it seems like there is > some sort of version conflict somewhere? It seems to me I have the > latest of everything in the right locations. >Tim, what''s on this line: /srv/www/mycms/public/../config/environment.rb:42 I don''t have an environment.rb handy, but I''m thinking that there will be a call to ''require_gem "something"'' there. You can help to narrow down the issue by doing that same require_gem call in irb (or a small script): require ''rubygems'' require_gem ''activerecord'' #for example to see if it fails in this mode. -- Chad Fowler http://chadfowler.com http://rubycentral.org http://rubygarden.org http://rubygems.rubyforge.org (over 100,000 gems served!)
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Joshua Wehner wrote: | I''m new to Ruby and Rails, and I''m not sure which is most responsible | for my confusion here. :) | | I have a minor legacy db issue: something that should be an int(3) is a | char(3) instead. And it needs to be increased by an offset number to | match other records. In PHP, this was fairly trivial, but in RoR, I''m | having a frustrating time with it. | | First, I tried this: | | def project_no | @project_num = project_num.to_i + 10 | someMethod (project_num) | end | | But this doesn''t work. someMethod always thinks that project_num is just | 10 (ie, to_i converted project_num to 0). So I tried this: | | def project_no | score = project_num.to_i | score += 10 | @project_num = score | someMethod = project_num | end | | And that worked. But it''s slightly ugly. And I, ultimately, I really | want something more like: | | def update_project_no | @project_num + 10 | end | | def project_no | @update_project_no | someMethod (project_num) | end | | | Can anybody straighten me out here? I''d be much obliged. Just redefine the accessor for project_num: class Project < ActiveRecord::Base ~ def project_num ~ read_attribute("project_num").to_i ~ end ~ def project_num=(number) ~ write_attribute("length", number.to_s) ~ end end - -- David Morton Maia Mailguard server side anti-spam/anti-virus solution: http://www.maiamailguard.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFCVuOvSIxC85HZHLMRAo9DAJwKReHDrV7aryKT9MO+2eZil7/JzgCdH730 TIBOhSunlAqe2gaapfbkiec=W4kU -----END PGP SIGNATURE-----
> Tim, what''s on this line:> > /srv/www/mycms/public/../config/environment.rb:42 Thanks for trying to help. On line 42 of environment.rb I have require_gem ''syntax'' which made me realize this gem was not installed for some reason and throwing an error. When a did a gem install syntax, I can now run the test script in irb. Cool... Unfortunately, now I''m getting a "SyntaxError in <controller not set>#<action not set>" error but at least I''m making progress. Thanks, Tim Chad Fowler wrote:> On Apr 8, 2005 3:06 PM, Tim Broeker <tim-lmTtMILVy1gjk9F/YNdkvQ@public.gmane.org> wrote: > >>Can anybody help me decipher this error from apache.log? I''ve scoured >>the lists/google for more info on this but I''m officially stumped. The >>details: >> >>- suse 9.2/apache2/ruby 1.8.2/gem 0.8.10 >> >>- When I run gem list everything looks fine >> >>- The rails "congrats" screen works fine at localhost >> >>- But when I try install hieraki (for example) all I get on the frontend >>is "Application Error (Apache)" >> >>This is a snippet of what I get in apache.log: >> >>[Fri Apr 08 13:51:52 2005] [error] [client 127.0.0.1] >>/usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:194:in `report_activate_error'' >>[Fri Apr 08 13:51:52 2005] [error] [client 127.0.0.1] : >>[Fri Apr 08 13:51:52 2005] [error] [client 127.0.0.1] Could not find >>RubyGem syntax (> 0.0.0) >>[Fri Apr 08 13:51:52 2005] [error] [client 127.0.0.1] ( >>[Fri Apr 08 13:51:52 2005] [error] [client 127.0.0.1] Gem::LoadError >>[Fri Apr 08 13:51:52 2005] [error] [client 127.0.0.1] ) >>[Fri Apr 08 13:51:52 2005] [error] [client 127.0.0.1] \tfrom >>/usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:136:in `activate'' >>[Fri Apr 08 13:51:52 2005] [error] [client 127.0.0.1] \tfrom >>/usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:37:in >>`require_gem_with_options'' >>[Fri Apr 08 13:51:52 2005] [error] [client 127.0.0.1] \tfrom >>/usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:31:in `require_gem'' >>[Fri Apr 08 13:51:52 2005] [error] [client 127.0.0.1] \tfrom >>/srv/www/mycms/public/../config/environment.rb:42 >>[Fri Apr 08 13:51:52 2005] [error] [client 127.0.0.1] \tfrom >>/srv/www/mycms/public/dispatch.cgi:3:in `require'' >>[Fri Apr 08 13:51:52 2005] [error] [client 127.0.0.1] \tfrom >>/srv/www/mycms/public/dispatch.cgi:3 >>[Fri Apr 08 13:51:52 2005] [error] [client 127.0.0.1] Premature end of >>script headers: dispatch.cgi >> >>I have double checked permissions and tried looking into the >>report_activate_error function in rubygems.rb - it seems like there is >>some sort of version conflict somewhere? It seems to me I have the >>latest of everything in the right locations. >> >