From go_mitchell at yahoo.ca Fri Oct 2 07:02:51 2009 From: go_mitchell at yahoo.ca (Mitchell Gould) Date: Fri, 2 Oct 2009 13:02:51 +0200 Subject: [Rails I18n] problems switching language after search form resuls Message-ID: <2ba285c5e57d6c968de1a9cd8932b9af@ruby-forum.com> I have a form that allows the user to search for a manufacturer. It works fine. Now I am making the site in two languages French and English. I have the basics of I18ln working as suggested in Agile Web Development book. However for this particular case there is a problem. If the user chooses to switch languages after the results come back the information is no longer being sent as a request.post. In the controller I test for this to make sure the information is coming from the form for security reason. #takes the information entered on the search products box and returns a list of possible matches. def search if request.post? @manufacturer_matches = Manufacturer.find_all(params[:manufacturer]) unless @manufacturer_matches[0] flash[:search] = t('manufacturers.search.flash', :manufacturer => params[:manufacturer] ) end end end (find all is a method in the Manufacturers model.) If i remove the request.post? potential hackers can get in and the parameters from the search box are not passed so the search returns nothing. Any ideas on the best practices to be -- Posted via http://www.ruby-forum.com/. From tm-ppatel at openkick.com Sat Oct 3 03:29:53 2009 From: tm-ppatel at openkick.com (Preksha Patel) Date: Sat, 3 Oct 2009 09:29:53 +0200 Subject: [Rails I18n] error occurs while using savage beast plugin Message-ID: Hi all, I am using savage-beast plugin for forum..i have integrated code with my application as given in readme file of savage-beast but now when i try to run /script/server it gives me following error: => Booting Mongrel => Rails 2.3.2 application starting on http://0.0.0.0:3000 /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/core_ext/module/aliasing.rb:33:in `alias_method': undefined method `initialize_schema_information' for module `ActiveRecord::ConnectionAdapters::SchemaStatements' (NameError) from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/core_ext/module/aliasing.rb:33:in `alias_method_chain' from /var/www/citiplots_staging/vendor/plugins/temp/engines/lib/engines/rails_extensions/migrations.rb:131:in `included' from /var/www/citiplots_staging/vendor/plugins/temp/engines/lib/engines/rails_extensions/migrations.rb:131:in `class_eval' from /var/www/citiplots_staging/vendor/plugins/temp/engines/lib/engines/rails_extensions/migrations.rb:131:in `included' from /var/www/citiplots_staging/vendor/plugins/temp/engines/lib/engines/rails_extensions/migrations.rb:155:in `include' from /var/www/citiplots_staging/vendor/plugins/temp/engines/lib/engines/rails_extensions/migrations.rb:155 from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' ... 26 levels... from /usr/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/commands/server.rb:84 from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from script/server:3 can any one please help me?? Thanks... -- Posted via http://www.ruby-forum.com/. From lipkinr at inter.net.il Mon Oct 12 11:22:56 2009 From: lipkinr at inter.net.il (Raffi Lipkin) Date: Mon, 12 Oct 2009 17:22:56 +0200 Subject: [Rails I18n] Telephone number validation and formatting Message-ID: <3e0948407906ea04bd2ad1c938cbb009@ruby-forum.com> I'm working to build a telephone number validation and formatting method. I'm attaching an address_helper I use for this. I'd like to get comments on it. The method is based on extending the country model by adding 4 integer attributes: tel_min, tel_max, tel_area_min and tel_area_max which are the minimum and maximum number of digits of the telephone number in each country and the minimum and maximum number of digits in the telephone area code. Please comment. Thanks, Raffi Attachments: http://www.ruby-forum.com/attachment/4139/address_helper.rb -- Posted via http://www.ruby-forum.com/. From sean.tan.sg at gmail.com Fri Oct 16 02:47:17 2009 From: sean.tan.sg at gmail.com (Sean Tan) Date: Fri, 16 Oct 2009 08:47:17 +0200 Subject: [Rails I18n] Very strange problem with Gettext and Haml In-Reply-To: <2a86ba5484349f785ccdc034058bf44f@ruby-forum.com> References: <2a86ba5484349f785ccdc034058bf44f@ruby-forum.com> Message-ID: Try modifying your haml_parser.rb to see where the parser gets stuck. def parse(file, ary = []) haml = Haml::Engine.new(IO.readlines(file).join) code = haml.precompiled.split(/$/) puts "Parsing Haml File: #{file}" RubyParser.parse_lines(file, code, ary) end I'm having problems of my own in upgrading my setup. Rails 2.3.4 gettext 2.0.4 haml 2.2.8 >From what I have gathered it is largely due to the change of in HAML 2.2 Engine that made it's output unparseable by the gettext's default RubyParser. I have tried the gems retoo-ruby_gettext_extractor (0.2.1) that depends on ruby_parser without success. This ruby_parser has a RubyParser class of it's own and conflicts with Gettext's RubyParser module. So here's a classical case of why we should namespace our code. -_- After hacking it to work by changing the names of the RubyParser in the gems, I can make it work to parse en template files, using retoo's gettext_extractor/rubyparser gems. However, the parser doesn't work on my non-latin template files. My HamlParser class as below. Anyone can have a go and fix this? A million thanks! # haml_parser.rb require 'rubygems' require 'haml' require 'gettext_rails/tools' require 'ruby_gettext_extractor' module HamlParser module_function def target?(file) File.extname(file) == '.haml' end def parse(file, ary = []) bypass = ! File.basename(file, '.haml').match(/(vi|zh|zh_HK|id|th)$/).nil? puts "HamlParser:#{file}:bypass:#{bypass}" return ary if bypass haml = Haml::Engine.new(IO.readlines(file).join) result = nil begin #result = GetText::RubyParser.parse_lines(file, haml.precompiled.split(/$/), ary) result = RubyGettextExtractor.parse_string(haml.precompiled, file, ary) rescue Exception => e puts "Error:#{file}" raise e end result end end GetText::RGetText.add_parser(HamlParser) -- Posted via http://www.ruby-forum.com/.