[Rails] Webrick script/server file does not exist
Hello all, I worked fairly enough with PHP and MySQL, but am very new to Ruby. I have Windows machine with Apache and MySQL installed previously. Both Apache and MySql were stopped while installing Ruby. I tried several ways to install Ruby 1.8.7 and one-step installer. I can use Ruby with netbeans 6.0.1 with its own Ruby or with the one I installed now. The problem starts when I try to create web ruby application. The command C:\Sites rails new helloworld creates the bunch of directories and files: create create README create Rakefile create config.ru create .gitignore create Gemfile create app create app/controllers/application_controller.rb create app/helpers/application_helper.rb create app/mailers create app/models create app/views/layouts/application.html.erb create config create config/routes.rb create config/application.rb create config/environment.rb create config/environments create config/environments/development.rb create config/environments/production.rb create config/environments/test.rb create config/initializers create config/initializers/backtrace_silencers.rb create config/initializers/inflections.rb create config/initializers/mime_types.rb create config/initializers/secret_token.rb create config/initializers/session_store.rb create config/locales create config/locales/en.yml create config/boot.rb create config/database.yml create db create db/seeds.rb create doc create doc/README_FOR_APP create lib create lib/tasks create lib/tasks/.gitkeep create log create log/server.log create log/production.log create log/development.log create log/test.log create public create public/404.html create public/422.html create public/500.html create public/favicon.ico create public/index.html create public/robots.txt create public/images create public/images/rails.png create public/stylesheets create public/stylesheets/.gitkeep create public/javascripts create public/javascripts/application.js create public/javascripts/controls.js create public/javascripts/dragdrop.js create public/javascripts/effects.js create public/javascripts/prototype.js create public/javascripts/rails.js create script create script/rails create test create test/fixtures create test/functional create test/integration create test/performance/browsing_test.rb create test/test_helper.rb create test/unit create tmp create tmp/sessions create tmp/sockets create tmp/cache create tmp/pids create vendor/plugins create vendor/plugins/.gitkeep But as you can see script directory contains only one file rails Here is its content: #!/usr/bin/env ruby.exe # This command will automatically be run when you run rails with Rails 3 gems installed from the root of your application. APP_PATH = File.expand_path('../../config/application', __FILE__) require File.expand_path('../../config/boot', __FILE__) require 'rails/commands' So the command C:\Sites\helloworld\ruby script/server to start WebRick does not work because script/server file does not exist. What do I do wrong? Please help Here is the list of gems: C:\Sitesgem list --local *** LOCAL GEMS *** abstract (1.0.0) actionmailer (3.0.6) actionpack (3.0.6) activemodel (3.0.6) activerecord (3.0.6) activeresource (3.0.6) activesupport (3.0.6) arel (2.0.9) builder (2.1.2) bundler (1.0.12) erubis (2.6.6) i18n (0.5.0) mail (2.2.15) mime-types (1.16) open4 (1.0.1) pg (0.10.1) Platform (0.4.0) polyglot (0.3.1) POpen4 (0.1.4) rack (1.2.2) rack-mount (0.6.14) rack-test (0.5.7) rails (3.0.6) railties (3.0.6) rake (0.8.7) rb-readline (0.4.0) rubyzip2 (2.0.1) sqlite3 (1.3.3 x86-mingw32) sqlite3-ruby (1.3.3) thor (0.14.6) treetop (1.4.9) tzinfo (0.3.26) win32-open3 (0.3.2 x86-mingw32) Thank you in advance. Maria -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Rails 3 Routes
Hi everyone, I have a nested resource that is generating the route: /events/id/ registrations.json However, I would like to know if I can do something like this: /events/ registrations.json With that said I have three questions: 1) If I can do that, would the events id still be passed and give me access to the proper registrations related to the event? 2) How does this look in my routes file? 3) Would there need to be a change in my controllers? You may find the code I am working with at: github.com/TheCodeBoutique/ Nested-Resource-Demo Kind Regards, Chad Eubanks The Code Boutique -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Rails 3 respond_with json question
Hello, Having trouble with generating some json. I am trying to render an single active record result to json like this: @data = User.find(1) respond_with(@data, :include = :status) The json result is: { -user: { address: null email: t...@email.com first_name: Test last_name: Man status_id: 1 username: testguy status: { } } } So whats the problem? The problem is that the :include=:status seems to not bring over the relation. In my User model I have a belongs_to :status. How do i get this to work on a single result set? When I do this: @data = User.where(id = 1) respond_with(@data, :include = :status) The relation shows in the json result set fine this way. But its within an array of objects, which i do not want. Any ideas? -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: My web developer has abandoned me with a Rails site. NEED HELP ASAP
I can help too, marcomon...@gmail.com On 8 mayo, 15:51, grouppicture p...@grouppicture.com wrote: Im looking for immediate help. My web developer had started building me a site in Rails and has since gone AWOL and now I need to change info on the site but I have ZERO experience with code of any type. I'm looking for a hero who can help walk me through editing some copy that needs to be done ASAP. thank you in advance. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Webrick script/server file does not exist
On 10 May 2011, at 19:12, Maria marajo...@gmail.com wrote: Hello all, I worked fairly enough with PHP and MySQL, but am very new to Ruby. I have Windows machine with Apache and MySQL installed previously. [snip] But as you can see script directory contains only one file rails The rails command line stuff changed a lot in rails 3, to start the server you now do rails server, to start the console it's rails console etc. Fred Here is its content: #!/usr/bin/env ruby.exe # This command will automatically be run when you run rails with Rails 3 gems installed from the root of your application. APP_PATH = File.expand_path('../../config/application', __FILE__) require File.expand_path('../../config/boot', __FILE__) require 'rails/commands' So the command C:\Sites\helloworld\ruby script/server to start WebRick does not work because script/server file does not exist. What do I do wrong? Please help Here is the list of gems: C:\Sitesgem list --local *** LOCAL GEMS *** abstract (1.0.0) actionmailer (3.0.6) actionpack (3.0.6) activemodel (3.0.6) activerecord (3.0.6) activeresource (3.0.6) activesupport (3.0.6) arel (2.0.9) builder (2.1.2) bundler (1.0.12) erubis (2.6.6) i18n (0.5.0) mail (2.2.15) mime-types (1.16) open4 (1.0.1) pg (0.10.1) Platform (0.4.0) polyglot (0.3.1) POpen4 (0.1.4) rack (1.2.2) rack-mount (0.6.14) rack-test (0.5.7) rails (3.0.6) railties (3.0.6) rake (0.8.7) rb-readline (0.4.0) rubyzip2 (2.0.1) sqlite3 (1.3.3 x86-mingw32) sqlite3-ruby (1.3.3) thor (0.14.6) treetop (1.4.9) tzinfo (0.3.26) win32-open3 (0.3.2 x86-mingw32) Thank you in advance. Maria -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Rails 3 Routes
On 10 May 2011, at 20:50, Banks chadcreat...@gmail.com wrote: Hi everyone, I have a nested resource that is generating the route: /events/id/ registrations.json However, I would like to know if I can do something like this: /events/ registrations.json With that said I have three questions: 1) If I can do that, would the events id still be passed and give me access to the proper registrations related to the event? Well the event id has to be somewhere, if not in the path then as a query param or in post data - you can't get rid of it completely if you need to know which event's registrations should be fetched Fred 2) How does this look in my routes file? 3) Would there need to be a change in my controllers? You may find the code I am working with at: github.com/TheCodeBoutique/ Nested-Resource-Demo Kind Regards, Chad Eubanks The Code Boutique -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Ajax request
On 10 May 2011, at 23:48, Mlle emsto...@gmail.com wrote: Hi I'm trying to create an Ajax request that displays a list of inventory items resulting from a search on a keyword. How can I insert the list of inventory items using a partial or a string of html onto the page following the ajax request? The following doesn't work because I can't use a content_tag helper method in a controller. You can have a view file for that action as you would for any other action Fred I guess another question would be why doesn't the inventories div update and show the inventory items after the ajax request? I have this in my controller (this uses a string of html) def find_by_keyword @inventories = Inventory.find(:all, :conditions = ['inventory_id LIKE ?', params[:inventory][:keyword]]) @inventories_list = @inventories.map { |inventory| content_tag(li, inventory['id'])} render :inline = @inventories_list end And this in the view: % form_remote_tag :url = { :controller = purchase_orders, :action = find_by_keyword }, :update= inventories do |f| -% %= model_auto_completer('inventory[keyword]', '', 'inventory[inventory_id]', '', {:method = :get})% %= submit_tag Find! % % end % div id = inventories % if !@inventories.nil?% % for inventory in @inventories % % link_to inventory['id'], :controller = purchase_orders, :action = new, :inventory_id = inventory['id'] % % end % % end % /div -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] help with validations
Hi, I am trying to use the new rails 3 validations and running into some issues. for my password I have, validates :password,:presence = {:on = :create}, :length = { :minimum = 5, :maximum = 16 }, :confirmation = true the presence and length are creating problem. I only want to be able to check for the password at create time to confirm if it is present. at update time if someone enters the password it should still match the size limit but it they do not enter the password then it should not be looked at. in my controller i have already added: params[:user].delete(:password) if params[:user][:password].blank? params[:user].delete(:password_confirmation) if params[:user][:password].blank? and params[:user][:password_confirmation].blank? to take care of any issue coming from that side. any help or suggestion will be greatly appriciated. -- Posted via http://www.ruby-forum.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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Constructing an array of stuff (to send multiple apple push notifications)
I'm using this gem https://github.com/justintv/APNS to send push notifications to an iPhone app and amazingly it works for single notifications, such that I can do... APNS.send_notification(Device.first.device_token,'test message') Works great... Now it should be a simple task (as per the docs to send multiple notifications) Gem says like this... device_token = '123abc456def' n1 = [device_token, :aps = { :alert = 'Hello...', :badge = 1, :sound = 'default' } n2 = [device_token, :aps = { :alert = '... iPhone!', :badge = 1, :sound = 'default' }] APNS.send_notifications([n1, n2]) # for me it's slightly different, I wish to loop through each device in my db and then send the same message to them all...it's something like this but it's clearly not quite right... can't get the :aps = thing to work out. I think I need something like this on my Device model, but it's not right - please help correct it, would greatly appreciate. def self.push_message_to_all(message) devices = self.all notifications = [] devices.each do |device| notifications [device.device_token,message] end APNS.send_notifications(notifications) end -- Posted via http://www.ruby-forum.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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Webrick script/server file does not exist
Started from Rails 3, the syntax to start a server is: rails server or shorter: rails s Regards On May 10, 7:12 pm, Maria marajo...@gmail.com wrote: Hello all, I worked fairly enough with PHP and MySQL, but am very new to Ruby. I have Windows machine with Apache and MySQL installed previously. Both Apache and MySql were stopped while installing Ruby. I tried several ways to install Ruby 1.8.7 and one-step installer. I can use Ruby with netbeans 6.0.1 with its own Ruby or with the one I installed now. The problem starts when I try to create web ruby application. The command C:\Sites rails new helloworld creates the bunch of directories and files: create create README create Rakefile create config.ru create .gitignore create Gemfile create app create app/controllers/application_controller.rb create app/helpers/application_helper.rb create app/mailers create app/models create app/views/layouts/application.html.erb create config create config/routes.rb create config/application.rb create config/environment.rb create config/environments create config/environments/development.rb create config/environments/production.rb create config/environments/test.rb create config/initializers create config/initializers/backtrace_silencers.rb create config/initializers/inflections.rb create config/initializers/mime_types.rb create config/initializers/secret_token.rb create config/initializers/session_store.rb create config/locales create config/locales/en.yml create config/boot.rb create config/database.yml create db create db/seeds.rb create doc create doc/README_FOR_APP create lib create lib/tasks create lib/tasks/.gitkeep create log create log/server.log create log/production.log create log/development.log create log/test.log create public create public/404.html create public/422.html create public/500.html create public/favicon.ico create public/index.html create public/robots.txt create public/images create public/images/rails.png create public/stylesheets create public/stylesheets/.gitkeep create public/javascripts create public/javascripts/application.js create public/javascripts/controls.js create public/javascripts/dragdrop.js create public/javascripts/effects.js create public/javascripts/prototype.js create public/javascripts/rails.js create script create script/rails create test create test/fixtures create test/functional create test/integration create test/performance/browsing_test.rb create test/test_helper.rb create test/unit create tmp create tmp/sessions create tmp/sockets create tmp/cache create tmp/pids create vendor/plugins create vendor/plugins/.gitkeep But as you can see script directory contains only one file rails Here is its content: #!/usr/bin/env ruby.exe # This command will automatically be run when you run rails with Rails 3 gems installed from the root of your application. APP_PATH = File.expand_path('../../config/application', __FILE__) require File.expand_path('../../config/boot', __FILE__) require 'rails/commands' So the command C:\Sites\helloworld\ruby script/server to start WebRick does not work because script/server file does not exist. What do I do wrong? Please help Here is the list of gems: C:\Sitesgem list --local *** LOCAL GEMS *** abstract (1.0.0) actionmailer (3.0.6) actionpack (3.0.6) activemodel (3.0.6) activerecord (3.0.6) activeresource (3.0.6) activesupport (3.0.6) arel (2.0.9) builder (2.1.2) bundler (1.0.12) erubis (2.6.6) i18n (0.5.0) mail (2.2.15) mime-types (1.16) open4 (1.0.1) pg (0.10.1) Platform (0.4.0) polyglot (0.3.1) POpen4 (0.1.4) rack (1.2.2) rack-mount (0.6.14) rack-test (0.5.7) rails (3.0.6) railties (3.0.6) rake (0.8.7) rb-readline (0.4.0) rubyzip2 (2.0.1) sqlite3 (1.3.3 x86-mingw32) sqlite3-ruby (1.3.3) thor (0.14.6) treetop (1.4.9) tzinfo (0.3.26) win32-open3 (0.3.2 x86-mingw32) Thank you in advance. Maria -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Webrick script/server file does not exist
Hi, In rails 3 the file in the script folder is called 'rails' and you need to pass in server (or s) as a parameter i.e. ruby script\rails server Hopefully it should now work Gary On May 10, 7:12 pm, Maria marajo...@gmail.com wrote: Hello all, I worked fairly enough with PHP and MySQL, but am very new to Ruby. I have Windows machine with Apache and MySQL installed previously. Both Apache and MySql were stopped while installing Ruby. I tried several ways to install Ruby 1.8.7 and one-step installer. I can use Ruby with netbeans 6.0.1 with its own Ruby or with the one I installed now. The problem starts when I try to create web ruby application. The command C:\Sites rails new helloworld creates the bunch of directories and files: create create README create Rakefile create config.ru create .gitignore create Gemfile create app create app/controllers/application_controller.rb create app/helpers/application_helper.rb create app/mailers create app/models create app/views/layouts/application.html.erb create config create config/routes.rb create config/application.rb create config/environment.rb create config/environments create config/environments/development.rb create config/environments/production.rb create config/environments/test.rb create config/initializers create config/initializers/backtrace_silencers.rb create config/initializers/inflections.rb create config/initializers/mime_types.rb create config/initializers/secret_token.rb create config/initializers/session_store.rb create config/locales create config/locales/en.yml create config/boot.rb create config/database.yml create db create db/seeds.rb create doc create doc/README_FOR_APP create lib create lib/tasks create lib/tasks/.gitkeep create log create log/server.log create log/production.log create log/development.log create log/test.log create public create public/404.html create public/422.html create public/500.html create public/favicon.ico create public/index.html create public/robots.txt create public/images create public/images/rails.png create public/stylesheets create public/stylesheets/.gitkeep create public/javascripts create public/javascripts/application.js create public/javascripts/controls.js create public/javascripts/dragdrop.js create public/javascripts/effects.js create public/javascripts/prototype.js create public/javascripts/rails.js create script create script/rails create test create test/fixtures create test/functional create test/integration create test/performance/browsing_test.rb create test/test_helper.rb create test/unit create tmp create tmp/sessions create tmp/sockets create tmp/cache create tmp/pids create vendor/plugins create vendor/plugins/.gitkeep But as you can see script directory contains only one file rails Here is its content: #!/usr/bin/env ruby.exe # This command will automatically be run when you run rails with Rails 3 gems installed from the root of your application. APP_PATH = File.expand_path('../../config/application', __FILE__) require File.expand_path('../../config/boot', __FILE__) require 'rails/commands' So the command C:\Sites\helloworld\ruby script/server to start WebRick does not work because script/server file does not exist. What do I do wrong? Please help Here is the list of gems: C:\Sitesgem list --local *** LOCAL GEMS *** abstract (1.0.0) actionmailer (3.0.6) actionpack (3.0.6) activemodel (3.0.6) activerecord (3.0.6) activeresource (3.0.6) activesupport (3.0.6) arel (2.0.9) builder (2.1.2) bundler (1.0.12) erubis (2.6.6) i18n (0.5.0) mail (2.2.15) mime-types (1.16) open4 (1.0.1) pg (0.10.1) Platform (0.4.0) polyglot (0.3.1) POpen4 (0.1.4) rack (1.2.2) rack-mount (0.6.14) rack-test (0.5.7) rails (3.0.6) railties (3.0.6) rake (0.8.7) rb-readline (0.4.0) rubyzip2 (2.0.1) sqlite3 (1.3.3 x86-mingw32) sqlite3-ruby (1.3.3) thor (0.14.6) treetop (1.4.9) tzinfo (0.3.26) win32-open3 (0.3.2 x86-mingw32) Thank you in advance. Maria -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Update instance variable to actual active record
I have three models as you can see below. class Watchedfamily ActiveRecord::Base has_many :watchedmembers, :dependent = :destroy accepts_nested_attributes_for :watchedmembers has_many :old_watchedmembers, :dependent = :destroy accepts_nested_attributes_for :old_watchedmembers end class OldWatchedmember ActiveRecord::Base belongs_to :watchedfamily end class Watchedmember ActiveRecord::Base belongs_to :watchedfamily end Now I have a method in my controller that is (for a given watchedfamily) copying all entries of watchedmembers to old_watchedmembers and then deleting the watchedmember entries. Finally I am updating the watchedfamily with new watchedmembers. I just need it for comparing old members with actual members. Everything is working great in my database. I only have one problem in the controller below. I need the @family.watchedmembers for a next step, but the problem is that the @family.watchedmembers variable has the old and the new members in its memory. The database is updated and correct! It is only the @family.watchedmembers variable that has both members in it. My solution is to just call again: '@watchedfamily = Watchedfamily.find(id)' to get the recent data from the db. Is that the only possibily or is that bad because of additional load on the db? id = params[:id] @watchedfamily = Watchedfamily.find(id) @watchedfamily.watchedmembers.each do |member| params = {:watchedfamily = {:old_watchedmembers_attributes = MyExistingMemberEntries } } @watchedfamily.update_attributes(params[:watchedfamily]) #copy watchedmember to old_watchedmember member.destroy #destroy watchedmember end params = {:watchedfamily = {:watchedmembers_attributes = MyNewMemberEntries } } @watchedfamily.update_attributes(params[:watchedfamily]) #create recent watchedmembers @watchedfamily = Watchedfamily.find(id) #call the variable again from the db to get the actual data! @watchedfamily.watchedmembers.each do |x| .#some code for the next step end I hope someone can give me a hint! Cheers, Sebastian -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: changing routes.rb
On 8 May 2011 13:52, Colin Law clan...@googlemail.com wrote: On 8 May 2011 13:46, Mohamed L. li...@ruby-forum.com wrote: Yeah I had changed to root :to= and restarted the server. Ok, my routes.rb= Debate::Application.routes.draw do resources :posts ... # You can have the root of your site routed with root # just remember to delete public/index.html. # root :to = home#index Unfortunately you have it commented out. Remove the # That's ok, don't mention it. Oh you didn't, never mind. Colin -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Rails 3 respond_with json question
On May 10, 2011, at 9:02 PM, mikefuzz wrote: Hello, Having trouble with generating some json. I am trying to render an single active record result to json like this: @data = User.find(1) What happens (is there any difference?) if you do this: @data = User.find(1, :include = :status) Walter respond_with(@data, :include = :status) The json result is: { -user: { address: null email: t...@email.com first_name: Test last_name: Man status_id: 1 username: testguy status: { } } } So whats the problem? The problem is that the :include=:status seems to not bring over the relation. In my User model I have a belongs_to :status. How do i get this to work on a single result set? When I do this: @data = User.where(id = 1) respond_with(@data, :include = :status) The relation shows in the json result set fine this way. But its within an array of objects, which i do not want. Any ideas? -- 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- t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en . -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] requests hanging
I think I have found a good solution for my background tasks. http://kr.github.com/beanstalkd/ http://railscasts.com/episodes/243-beanstalkd-and-stalker It's exactly what I need, and it seems to be a simple and popular solution. On Tue, May 10, 2011 at 11:43 AM, Alex Katebi alex.kat...@gmail.com wrote: On Tue, May 10, 2011 at 11:01 AM, David Kahn d...@structuralartistry.comwrote: On Tue, May 10, 2011 at 9:56 AM, David Kahn d...@structuralartistry.comwrote: On Tue, May 10, 2011 at 9:45 AM, Alex Katebi alex.kat...@gmail.comwrote: I have restarted the server but not the computer. I am doing something abnormal. Off of a request I start some external program as sub processes. It takes about one second to start those sub processes. Maybe you could post your code. One thing you might want to look at is if you can start it using another thread -- I avoided using Threads since I wanted my operations to be atomic. especially if you have something which is apparently volatile. I call terminal commands all the time from my code, so itself should not be a problem. One way to do this could be delayed_job but you can probably do it much more simply using a new thread. See: http://www.ruby-doc.org/core/classes/Thread.html this looks pretty good as an intro to threading, if it turns out that this is the correct route to go: http://rubylearning.com/satishtalim/ruby_threads.html I guess though if your process is important you will have to add some handling in the case of failure if it were to happen. How long are we allowed to delay the sending of a respond? Is there a better way do this in Rails way? This problem is intermittent. On Tue, May 10, 2011 at 10:29 AM, David Kahn d...@structuralartistry.com wrote: On Tue, May 10, 2011 at 9:25 AM, Alex Katebi alex.kat...@gmail.comwrote: I see nothing any where. To clarify, on your server terminal window, you see no output when you try to access a page? And of course the page does not load, I assume. It is probably not this if you are seeing nothing at all on the terminal, but sometimes if I forget to remove a debugger line and still am running the server in --debugger mode then of course it hangs. Otherwise, other obvious quations: have you restarted the server? As well, restarted your computer? On Mon, May 9, 2011 at 4:58 PM, Colin Law clan...@googlemail.comwrote: On 9 May 2011 21:54, Alex Katebi alex.kat...@gmail.com wrote: If my Rails server has been sitting idle for a while, it does not respond to new requests. What is the best way to troubleshoot something like that. I am using Rails 3.0.7 in development. Is there anything in development.log when you submit the request (or already there indicating a problem before the request)? What about in the server terminal window? Colin -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com . To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com.
[Rails] Re: Rails 3 respond_with json question
That doesn't work. Then it displays this: { -user: { address: null email: t...@test.com first_name: Test last_name: Man status_id: 1 username: test } } On May 10, 6:02 pm, mikefuzz m...@michaeljaffe.com wrote: Hello, Having trouble with generating some json. I am trying to render an single active record result to json like this: @data = User.find(1) respond_with(@data, :include = :status) The json result is: { -user: { address: null email: t...@email.com first_name: Test last_name: Man status_id: 1 username: testguy status: { } } } So whats the problem? The problem is that the :include=:status seems to not bring over the relation. In my User model I have a belongs_to :status. How do i get this to work on a single result set? When I do this: @data = User.where(id = 1) respond_with(@data, :include = :status) The relation shows in the json result set fine this way. But its within an array of objects, which i do not want. Any ideas? -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Call a task when server starts
hi, I am trying to invoke a task when server start but fails to do that. Can any body help me that how to do it? My code is: *path* : app_root/lib/tasks/mytask.rake task :start = :environment do #do some magic and start the cron puts started! system(start) end task :stop do #do some more magic and stop IT puts stops! end ** -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Call a task when server starts
Could you put the code in an initializer? -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] News Aanad wants to chat
--- News Aanad wants to stay in better touch using some of Google's coolest new products. If you already have Gmail or Google Talk, visit: http://mail.google.com/mail/b-b01e394238-6f1d3facf2-IYlUEQAwhdKx3zoyeh5BuVvbsCQ You'll need to click this link to be able to chat with News Aanad. To get Gmail - a free email account from Google with over 2,800 megabytes of storage - and chat with News Aanad, visit: http://mail.google.com/mail/a-b01e394238-6f1d3facf2-IYlUEQAwhdKx3zoyeh5BuVvbsCQ Gmail offers: - Instant messaging right inside Gmail - Powerful spam protection - Built-in search for finding your messages and a helpful way of organizing emails into conversations - No pop-up ads or untargeted banners - just text ads and related information that are relevant to the content of your messages All this, and its yours for free. But wait, there's more! By opening a Gmail account, you also get access to Google Talk, Google's instant messaging service: http://www.google.com/talk/ Google Talk offers: - Web-based chat that you can use anywhere, without a download - A contact list that's synchronized with your Gmail account - Free, high quality PC-to-PC voice calls when you download the Google Talk client We're working hard to add new features and make improvements, so we might also ask for your comments and suggestions periodically. We appreciate your help in making our products even better! Thanks, The Google Team To learn more about Gmail and Google Talk, visit: http://mail.google.com/mail/help/about.html http://www.google.com/talk/about.html (If clicking the URLs in this message does not work, copy and paste them into the address bar of your browser). -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Sign in problem with IE
What's the specific problem you are having with IE8? Posting some relevant code and error messages may help with troubleshooting. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: Call a task when server starts
but how can i run that??? my actual code is like: task :start = :environment do #do some magic and start the cron while true do #http_request_and_response_code end end task :stop do #do some more magic and stop IT puts stops! end On Wed, May 11, 2011 at 6:52 PM, Tim Shaffer timshaf...@me.com wrote: Could you put the code in an initializer? -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Regex Validation
Hi there, Anybody knows how to use regex to validate street name field? I want to avoid things like st asdkskjfls çsdfksçf. Thanks, Pedro -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Getting null value when it's assigned
I'm assuming the problem happens when creating new records. Can we see the new and create actions in your controller and the full form in the view? Also, are there any before/after/around filters and/or callbacks that could be affecting the behavior of the application? On May 10, 8:19 pm, Tomas R. li...@ruby-forum.com wrote: I have my articles migration create_table :articles do |t| t.integer :category_id, :null = false etc.. and my form Select a category %= f.select :category_id, Category.all.collect {|category| [category.name, category.id ]} % But everytime im sending that info im getting a nil value for category_id -- Posted viahttp://www.ruby-forum.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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Autocomplete plugin
If I understand well the question the answer should be yes. If what you mean is if it is possible to use one field on a page to find data in more than one column in the table it should be possible the only thing you would need is to query the table by the columns you desire to query on. On May 10, 7:23 pm, Mlle emsto...@gmail.com wrote: Hi Is it possible to use the autocomplete plugin to search using a keyword on more than one field of a model? How can I do that? -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Regex Validation
I don't think a regex can save you here. Ask yourself a higher-level question. Why are you gathering the address information, and why isn't it optional? If it's to send something of value to the person you're requesting it from by postal mail, or if you're using it to help them find something they need nearby their home, then rest assured they will enter it with care. If it's anything less, you invite this sort of abuse, and you should either just stop asking the question, or realize that a significant percentage of entries will be undeliverable (to use the Post Office's bloodless euphemism). By the way, I believe the USPS has an address checker API, IIRC, I've used it from PHP before, and there may be a Gem wrapper for it as well. Ditto FedEx if you're using them for delivery. Walter On May 11, 2011, at 9:39 AM, Pedro wrote: Hi there, Anybody knows how to use regex to validate street name field? I want to avoid things like st asdkskjfls çsdfksçf. Thanks, Pedro -- 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- t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en . -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Autocomplete plugin
On May 10, 2011, at 7:23 PM, Mlle wrote: Hi Is it possible to use the autocomplete plugin to search using a keyword on more than one field of a model? How can I do that? When you use autocompletion, you define a field to watch, and an endpoint to query against. Whatever query conditions you put in the method that answers that endpoint will be the results that appear in the autocompleter's list. So if you had generated: new Ajax.Autocompleter('person','/people/lookup',{}); Then in Person#lookup you would be looking for Person.all(:conditions = ['first_name LIKE ? OR last_name LIKE ?'],#{params[:value]}%,#{params[:value]}%]) Crude example, but you get the idea... Walter -- 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- t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en . -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: Call a task when server starts
I guess it might help to understand what your code is trying to do. But if this is the code you want to execute when the server starts: #do some magic and start the cron You could just put that in an initializer, and it will be executed when the server starts. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Help save my marriage ... correct route, so enable MVC logic v's should be regular file, trying to send it
Hi All, I've been up until the small hours for the past couple of night trying to get my Rhodes navigation working! In essence I have the following in the root index.erb li a href=%= url_for :controller = :Model, :action = :do_Action %Model/a /li li a href=%= url_for :controller = :Model2, :action = :do_Action2 %Model2/a /li However, Model and Model2 behave differently, thus: Extract from rholog.txt ... HttpServer| Decide what to do with uri /app/Model/do_Action HttpServer| Uri /app/Model/do_Action is correct route, so enable MVC logic ... HttpServer| Decide what to do with uri /app/OtherModel/do_OtherAction HttpServer| Uri /app/OtherModel/do_OtherAction should be regular file, trying to send it ... resulting in ... HTTP/1.1 404 Not Found ... So my question really boils down to what does the framework use to decide whether to treat the request as either a correct route therefore invoking the MVC logic or as a regular file, which will never be found as do_OtherAction doesn't exist! Many thanks in advance, Cheers, Jason -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] method_missing in controller
Hi, I am using a method_missing method into a controller. I have a route that says: match ':controller/:action' What surprise me is that if a view that match the action name exists method_missing is not invoked but rails happily render the view. I was expecting that method_missing was going to be invoked if declarated. Is that a normal behaviour? Thanks Andrea -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] ROR 3 model associations
Hi all, I am new to ROR3 and would really appreciate some advice on how to define the following model association: Game model - has host_userid and visitor_userid as fields to define the two players engaged in the game. this two fields are of type User and need to be mapped via foreign key relationship. User model - a user object can belong to one or more games (as I imagine .. I would fetch that by querying the Games table where the host_userid or visitor_userid equal to the userid in question) if anyone could post a code snippet to define such associations Id be really grateful :) -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Regex Validation
Walter Im using address to geocoding. Do you know if exists an address check plugin or gem to do this work? Thanks Pedro On 11 maio, 10:54, Walter Davis wa...@wdstudio.com wrote: I don't think a regex can save you here. Ask yourself a higher-level question. Why are you gathering the address information, and why isn't it optional? If it's to send something of value to the person you're requesting it from by postal mail, or if you're using it to help them find something they need nearby their home, then rest assured they will enter it with care. If it's anything less, you invite this sort of abuse, and you should either just stop asking the question, or realize that a significant percentage of entries will be undeliverable (to use the Post Office's bloodless euphemism). By the way, I believe the USPS has an address checker API, IIRC, I've used it from PHP before, and there may be a Gem wrapper for it as well. Ditto FedEx if you're using them for delivery. Walter On May 11, 2011, at 9:39 AM, Pedro wrote: Hi there, Anybody knows how to use regex to validate street name field? I want to avoid things like st asdkskjfls çsdfksçf. Thanks, Pedro -- 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- t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com . For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en . -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: Regex Validation
On May 11, 2011, at 10:18 AM, Pedro wrote: Walter Im using address to geocoding. Do you know if exists an address check plugin or gem to do this work? Thanks Pedro I repeat my earlier point. If it's not valuable enough to the user, they will spam you like this. If your geocoder reports an error, then raise it to the user, tell him or her sorry, having trouble with that location, could you check the address again? You may be able to find a gem that wraps the USPS database, or FedEx's (with an API key from FedEx, and weeks of back-and-forth with their approval team). But it still gets back to the original value to the user question. What exactly do you give them in return for their successful entry of a real address? Do *they* think it's valuable? Walter On 11 maio, 10:54, Walter Davis wa...@wdstudio.com wrote: I don't think a regex can save you here. Ask yourself a higher-level question. Why are you gathering the address information, and why isn't it optional? If it's to send something of value to the person you're requesting it from by postal mail, or if you're using it to help them find something they need nearby their home, then rest assured they will enter it with care. If it's anything less, you invite this sort of abuse, and you should either just stop asking the question, or realize that a significant percentage of entries will be undeliverable (to use the Post Office's bloodless euphemism). By the way, I believe the USPS has an address checker API, IIRC, I've used it from PHP before, and there may be a Gem wrapper for it as well. Ditto FedEx if you're using them for delivery. Walter On May 11, 2011, at 9:39 AM, Pedro wrote: Hi there, Anybody knows how to use regex to validate street name field? I want to avoid things like st asdkskjfls çsdfksçf. Thanks, Pedro -- 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- t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com . For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en . -- 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- t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en . -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Getting null value when it's assigned
On 11 May 2011 01:19, Tomas R. li...@ruby-forum.com wrote: I have my articles migration create_table :articles do |t| t.integer :category_id, :null = false etc.. and my form Select a category %= f.select :category_id, Category.all.collect {|category| [category.name, category.id ]} % But everytime im sending that info im getting a nil value for category_id First look in development.log to see if it is being passed with the request ok. Then use ruby-debug to break into your code in the controller action (create or update presumably) and you can inspect the data to work out where it is getting lost. See the Rails Guide on debugging to find how to do that. Colin -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: Regex Validation
Walter Im using address to geocoding. Do you know if exists an address check plugin or gem to do this work? Thanks Pedro I repeat my earlier point. If it's not valuable enough to the user, they will spam you like this. If your geocoder reports an error, then raise it to the user, tell him or her sorry, having trouble with that location, could you check the address again? You may be able to find a gem that wraps the USPS database, or FedEx's (with an API key from FedEx, and weeks of back-and-forth with their approval team). But it still gets back to the original value to the user question. What exactly do you give them in return for their successful entry of a real address? Do *they* think it's valuable? +1 for everything Walter has said about requiring it... Also... my memory is that yes the USPS has this ability, but it's not free (and quite expensive). Google can do it as well. Look into the geokit-rails stuff. It won't help with sanitizing the input, but it will turn it into a lat/long pair if it can. If location isn't super super important, just ask for their zip code. That's certainly granular enough to do nearby type functionality. Good luck! -philip Walter On 11 maio, 10:54, Walter Davis wa...@wdstudio.com wrote: I don't think a regex can save you here. Ask yourself a higher-level question. Why are you gathering the address information, and why isn't it optional? If it's to send something of value to the person you're requesting it from by postal mail, or if you're using it to help them find something they need nearby their home, then rest assured they will enter it with care. If it's anything less, you invite this sort of abuse, and you should either just stop asking the question, or realize that a significant percentage of entries will be undeliverable (to use the Post Office's bloodless euphemism). By the way, I believe the USPS has an address checker API, IIRC, I've used it from PHP before, and there may be a Gem wrapper for it as well. Ditto FedEx if you're using them for delivery. Walter On May 11, 2011, at 9:39 AM, Pedro wrote: Hi there, Anybody knows how to use regex to validate street name field? I want to avoid things like st asdkskjfls çsdfksçf. Thanks, Pedro -- 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- t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com . For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en . -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Rails 3 Routes
Fred, I understand I can not get rid of it completely. The reason I am asking this is this: I have a client side app that sets a proxy to the URL path with an extension .json. The events id is not a constant integer and therefore I can not set the proxy URL to an explicit events id. I need to have a constant URL path of events/registrations.json. From what you are saying. It sounds like it can be done but can you elaborate for me please. This might be a better example: users/id/posts.json. When user one logs in the related posts are shown. When user two logs in the related posts are shown. However, the id can not be shown in the url. Kind Regards, Chad Eubanks Sent from my iPhone On May 10, 2011, at 11:54 PM, Frederick Cheung frederick.che...@gmail.com wrote: On 10 May 2011, at 20:50, Banks chadcreat...@gmail.com wrote: Hi everyone, I have a nested resource that is generating the route: /events/id/ registrations.json However, I would like to know if I can do something like this: /events/ registrations.json With that said I have three questions: 1) If I can do that, would the events id still be passed and give me access to the proper registrations related to the event? Well the event id has to be somewhere, if not in the path then as a query param or in post data - you can't get rid of it completely if you need to know which event's registrations should be fetched Fred 2) How does this look in my routes file? 3) Would there need to be a change in my controllers? You may find the code I am working with at: github.com/TheCodeBoutique/ Nested-Resource-Demo Kind Regards, Chad Eubanks The Code Boutique -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: Call a task when server starts
I agree with you Tim but I have tried this idea. Whats happen is server is started but the service on the particular port is not being start because of that forever loop, this one is being problem in my app. Can u give me any more suggestion? and ya one more thing I don't want to use Thread class.. Thanks Tim. On Wed, May 11, 2011 at 7:39 PM, Tim Shaffer timshaf...@me.com wrote: I guess it might help to understand what your code is trying to do. But if this is the code you want to execute when the server starts: #do some magic and start the cron You could just put that in an initializer, and it will be executed when the server starts. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: ROR 3 model associations
If you phrase it slightly differently, the code for associations almost writes itself: Game has one host to class User Game has one visitor to class User User has many hosting games to class Game User has many visiting games to class Game By default when you create an association, rails will use the model name plus _id to determine the foreign key. This isn't what you want, since game has 2 foreign keys to user. Adding the class_name option makes it use the name of the association and the class name plus _id. In this case, host_user_id and visitor_user_id. So you can define it like this: class Game has_one :host, :class_name = User, :inverse_of = :hosting_games has_one :visitor, :class_name = User, :inverse_of = :visiting_games end class User has_many :hosting_games, :class_name = Game, :inverse_of = :host has_many :visiting_games, :class_name = Game, :inverse_of = :visitor end -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] requests hanging
On Wed, May 11, 2011 at 7:26 AM, Alex Katebi alex.kat...@gmail.com wrote: I think I have found a good solution for my background tasks. http://kr.github.com/beanstalkd/ http://railscasts.com/episodes/243-beanstalkd-and-stalker It's exactly what I need, and it seems to be a simple and popular solution. Thanks for sharing... I had not seen this and good to know about On Tue, May 10, 2011 at 11:43 AM, Alex Katebi alex.kat...@gmail.comwrote: On Tue, May 10, 2011 at 11:01 AM, David Kahn d...@structuralartistry.comwrote: On Tue, May 10, 2011 at 9:56 AM, David Kahn d...@structuralartistry.comwrote: On Tue, May 10, 2011 at 9:45 AM, Alex Katebi alex.kat...@gmail.comwrote: I have restarted the server but not the computer. I am doing something abnormal. Off of a request I start some external program as sub processes. It takes about one second to start those sub processes. Maybe you could post your code. One thing you might want to look at is if you can start it using another thread -- I avoided using Threads since I wanted my operations to be atomic. especially if you have something which is apparently volatile. I call terminal commands all the time from my code, so itself should not be a problem. One way to do this could be delayed_job but you can probably do it much more simply using a new thread. See: http://www.ruby-doc.org/core/classes/Thread.html this looks pretty good as an intro to threading, if it turns out that this is the correct route to go: http://rubylearning.com/satishtalim/ruby_threads.html I guess though if your process is important you will have to add some handling in the case of failure if it were to happen. How long are we allowed to delay the sending of a respond? Is there a better way do this in Rails way? This problem is intermittent. On Tue, May 10, 2011 at 10:29 AM, David Kahn d...@structuralartistry.com wrote: On Tue, May 10, 2011 at 9:25 AM, Alex Katebi alex.kat...@gmail.comwrote: I see nothing any where. To clarify, on your server terminal window, you see no output when you try to access a page? And of course the page does not load, I assume. It is probably not this if you are seeing nothing at all on the terminal, but sometimes if I forget to remove a debugger line and still am running the server in --debugger mode then of course it hangs. Otherwise, other obvious quations: have you restarted the server? As well, restarted your computer? On Mon, May 9, 2011 at 4:58 PM, Colin Law clan...@googlemail.comwrote: On 9 May 2011 21:54, Alex Katebi alex.kat...@gmail.com wrote: If my Rails server has been sitting idle for a while, it does not respond to new requests. What is the best way to troubleshoot something like that. I am using Rails 3.0.7 in development. Is there anything in development.log when you submit the request (or already there indicating a problem before the request)? What about in the server terminal window? Colin -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com . To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to
[Rails] Re: Constructing an array of stuff (to send multiple apple push notifications)
Any ideas? -- Posted via http://www.ruby-forum.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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] requests hanging
On Wed, May 11, 2011 at 11:05 AM, David Kahn d...@structuralartistry.comwrote: On Wed, May 11, 2011 at 7:26 AM, Alex Katebi alex.kat...@gmail.comwrote: I think I have found a good solution for my background tasks. http://kr.github.com/beanstalkd/ http://railscasts.com/episodes/243-beanstalkd-and-stalker It's exactly what I need, and it seems to be a simple and popular solution. Thanks for sharing... I had not seen this and good to know about Sure! And thanks to Railscasts new and improved website that lists subject categories . On Tue, May 10, 2011 at 11:43 AM, Alex Katebi alex.kat...@gmail.comwrote: On Tue, May 10, 2011 at 11:01 AM, David Kahn d...@structuralartistry.comwrote: On Tue, May 10, 2011 at 9:56 AM, David Kahn d...@structuralartistry.comwrote: On Tue, May 10, 2011 at 9:45 AM, Alex Katebi alex.kat...@gmail.comwrote: I have restarted the server but not the computer. I am doing something abnormal. Off of a request I start some external program as sub processes. It takes about one second to start those sub processes. Maybe you could post your code. One thing you might want to look at is if you can start it using another thread -- I avoided using Threads since I wanted my operations to be atomic. especially if you have something which is apparently volatile. I call terminal commands all the time from my code, so itself should not be a problem. One way to do this could be delayed_job but you can probably do it much more simply using a new thread. See: http://www.ruby-doc.org/core/classes/Thread.html this looks pretty good as an intro to threading, if it turns out that this is the correct route to go: http://rubylearning.com/satishtalim/ruby_threads.html I guess though if your process is important you will have to add some handling in the case of failure if it were to happen. How long are we allowed to delay the sending of a respond? Is there a better way do this in Rails way? This problem is intermittent. On Tue, May 10, 2011 at 10:29 AM, David Kahn d...@structuralartistry.com wrote: On Tue, May 10, 2011 at 9:25 AM, Alex Katebi alex.kat...@gmail.comwrote: I see nothing any where. To clarify, on your server terminal window, you see no output when you try to access a page? And of course the page does not load, I assume. It is probably not this if you are seeing nothing at all on the terminal, but sometimes if I forget to remove a debugger line and still am running the server in --debugger mode then of course it hangs. Otherwise, other obvious quations: have you restarted the server? As well, restarted your computer? On Mon, May 9, 2011 at 4:58 PM, Colin Law clan...@googlemail.comwrote: On 9 May 2011 21:54, Alex Katebi alex.kat...@gmail.com wrote: If my Rails server has been sitting idle for a while, it does not respond to new requests. What is the best way to troubleshoot something like that. I am using Rails 3.0.7 in development. Is there anything in development.log when you submit the request (or already there indicating a problem before the request)? What about in the server terminal window? Colin -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this
[Rails] Re: Re: each do js problem
Jeffrey L. Taylor wrote in post #997862: div id=%= remark_#{comment[:id]} % HTH, Jeffrey Thanks that did the trick but I applied it to div id=subcomNormal Neil -- Posted via http://www.ruby-forum.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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: method_missing in controller
On May 11, 2:54 pm, andreacfm acampolon...@gmail.com wrote: Hi, I am using a method_missing method into a controller. I have a route that says: match ':controller/:action' What surprise me is that if a view that match the action name exists method_missing is not invoked but rails happily render the view. I was expecting that method_missing was going to be invoked if declarated. Is that a normal behaviour? Yes - you don't need an empty method body if all you want to do is render a template (although you might consider it more readable code if there was an empty method body) Fred -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] sequel
anyone using sequel with rails? any references regarding comparing sequel with other solutions(vs ActiveRecord, vs DataMapper and so on)? thanks in advance. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: method_missing in controller
Thanks. Was is not clear is why the method_missing method is not invoked if I declare it. Looks like rails render the view if exists before checking if a method_missing exists in the controller. Andrea On May 11, 5:12 pm, Frederick Cheung frederick.che...@gmail.com wrote: On May 11, 2:54 pm, andreacfm acampolon...@gmail.com wrote: Hi, I am using a method_missing method into a controller. I have a route that says: match ':controller/:action' What surprise me is that if a view that match the action name exists method_missing is not invoked but rails happily render the view. I was expecting that method_missing was going to be invoked if declarated. Is that a normal behaviour? Yes - you don't need an empty method body if all you want to do is render a template (although you might consider it more readable code if there was an empty method body) Fred -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Constructing an array of stuff (to send multiple apple push notifications)
On 11 May 2011 08:55, bingo bob li...@ruby-forum.com wrote: I'm using this gem https://github.com/justintv/APNS to send push notifications to an iPhone app and amazingly it works for single notifications, such that I can do... APNS.send_notification(Device.first.device_token,'test message') Works great... Now it should be a simple task (as per the docs to send multiple notifications) Gem says like this... device_token = '123abc456def' n1 = [device_token, :aps = { :alert = 'Hello...', :badge = 1, :sound = 'default' } n2 = [device_token, :aps = { :alert = '... iPhone!', :badge = 1, :sound = 'default' }] APNS.send_notifications([n1, n2]) Have you tried that? It doesn't look like valid ruby to me (even with the missing ] on the end of n1) # for me it's slightly different, I wish to loop through each device in my db and then send the same message to them all...it's something like this but it's clearly not quite right... can't get the :aps = thing to work out. I think I need something like this on my Device model, but it's not right - please help correct it, would greatly appreciate. def self.push_message_to_all(message) devices = self.all notifications = [] devices.each do |device| notifications [device.device_token,message] end Once you have got the manual example above working the use ruby-debug to break in here and have a look at notifications and see if it is of the same form as if you break into the manual test and look at it there. Colin -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: Regex Validation
+1 to everything Walter has said, as well. I haven't thought about this a lot, but doesn't this apply to everything in terms of user input? Doesn't this really enter the realm of a basic guideline, principle, or law for UI? (I remember something like this being applied to database design.) Don't make people enter data that they don't care about. Don't make people enter data that doesn't affect anything. Carefully evaluate whether people really need to enter data. If people feel free to enter garbage in a field, should that data really be asked for? Aren't there, potentially, corollaries to this? For instance, Always allow the people entering data to easily correct or remove their data. Fred On Wed, May 11, 2011 at 9:55 AM, Philip Hallstrom phi...@pjkh.com wrote: Walter Im using address to geocoding. Do you know if exists an address check plugin or gem to do this work? Thanks Pedro I repeat my earlier point. If it's not valuable enough to the user, they will spam you like this. If your geocoder reports an error, then raise it to the user, tell him or her sorry, having trouble with that location, could you check the address again? You may be able to find a gem that wraps the USPS database, or FedEx's (with an API key from FedEx, and weeks of back-and-forth with their approval team). But it still gets back to the original value to the user question. What exactly do you give them in return for their successful entry of a real address? Do *they* think it's valuable? +1 for everything Walter has said about requiring it... Also... my memory is that yes the USPS has this ability, but it's not free (and quite expensive). Google can do it as well. Look into the geokit-rails stuff. It won't help with sanitizing the input, but it will turn it into a lat/long pair if it can. If location isn't super super important, just ask for their zip code. That's certainly granular enough to do nearby type functionality. Good luck! -philip Walter On 11 maio, 10:54, Walter Davis wa...@wdstudio.com wrote: I don't think a regex can save you here. Ask yourself a higher-level question. Why are you gathering the address information, and why isn't it optional? If it's to send something of value to the person you're requesting it from by postal mail, or if you're using it to help them find something they need nearby their home, then rest assured they will enter it with care. If it's anything less, you invite this sort of abuse, and you should either just stop asking the question, or realize that a significant percentage of entries will be undeliverable (to use the Post Office's bloodless euphemism). By the way, I believe the USPS has an address checker API, IIRC, I've used it from PHP before, and there may be a Gem wrapper for it as well. Ditto FedEx if you're using them for delivery. Walter On May 11, 2011, at 9:39 AM, Pedro wrote: Hi there, Anybody knows how to use regex to validate street name field? I want to avoid things like st asdkskjfls çsdfksçf. Thanks, Pedro -- 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- t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com . For more options, visit this group athttp:// groups.google.com/group/rubyonrails-talk?hl=en . -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at
[Rails] Re: Autocomplete plugin
Thanks for your comments. I understand what you're saying but I guess my question had more to do with the population of the actual list, not the database query. If you use the autocomplete plugin, the list that populates under the input box has to be a certain field of a certain model. For example, when you call this helper: model_auto_completer_result(@inventories, :inventory_id ) the inventory_id is displayed for each inventory item matching the query. I'd like to search on two fields in the inventories table and display whichever field matched in the autocomplete list. On May 11, 10:05 am, Walter Davis wa...@wdstudio.com wrote: On May 10, 2011, at 7:23 PM, Mlle wrote: Hi Is it possible to use the autocomplete plugin to search using a keyword on more than one field of a model? How can I do that? When you use autocompletion, you define a field to watch, and an endpoint to query against. Whatever query conditions you put in the method that answers that endpoint will be the results that appear in the autocompleter's list. So if you had generated: new Ajax.Autocompleter('person','/people/lookup',{}); Then in Person#lookup you would be looking for Person.all(:conditions = ['first_name LIKE ? OR last_name LIKE ?'],#{params[:value]}%,#{params[:value]}%]) Crude example, but you get the idea... Walter -- 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- t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com . For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en . -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Help save my marriage ... correct route, so enable MVC logic v's should be regular file, trying to send it
which tool you are using to develop Rhodes applications? On Wed, May 11, 2011 at 6:53 PM, Jason jason.mcneil@googlemail.comwrote: Hi All, I've been up until the small hours for the past couple of night trying to get my Rhodes navigation working! In essence I have the following in the root index.erb li a href=%= url_for :controller = :Model, :action = :do_Action %Model/a /li li a href=%= url_for :controller = :Model2, :action = :do_Action2 %Model2/a /li However, Model and Model2 behave differently, thus: Extract from rholog.txt ... HttpServer| Decide what to do with uri /app/Model/do_Action HttpServer| Uri /app/Model/do_Action is correct route, so enable MVC logic ... HttpServer| Decide what to do with uri /app/OtherModel/do_OtherAction HttpServer| Uri /app/OtherModel/do_OtherAction should be regular file, trying to send it ... resulting in ... HTTP/1.1 404 Not Found ... So my question really boils down to what does the framework use to decide whether to treat the request as either a correct route therefore invoking the MVC logic or as a regular file, which will never be found as do_OtherAction doesn't exist! Many thanks in advance, Cheers, Jason -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: Call a task when server starts
That actually makes sense. Rails waits for the initializer to finish running before running the rest of your application. So if you have an infinite loop in there, it'll never finish running. Might be best to spawn another process using Thread or just run that code as part of a cron job or other manual process. Would help to understand what your code is trying to do. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: Autocomplete plugin
On May 11, 2011, at 11:27 AM, Mlle wrote: Thanks for your comments. I understand what you're saying but I guess my question had more to do with the population of the actual list, not the database query. If you use the autocomplete plugin, the list that populates under the input box has to be a certain field of a certain model. For example, when you call this helper: model_auto_completer_result(@inventories, :inventory_id ) the inventory_id is displayed for each inventory item matching the query. I'd like to search on two fields in the inventories table and display whichever field matched in the autocomplete list. Back up to the line where you define @inventories. That's where you would make the filter broad enough to include hits on more than one field. Walter On May 11, 10:05 am, Walter Davis wa...@wdstudio.com wrote: On May 10, 2011, at 7:23 PM, Mlle wrote: Hi Is it possible to use the autocomplete plugin to search using a keyword on more than one field of a model? How can I do that? When you use autocompletion, you define a field to watch, and an endpoint to query against. Whatever query conditions you put in the method that answers that endpoint will be the results that appear in the autocompleter's list. So if you had generated: new Ajax.Autocompleter('person','/people/lookup',{}); Then in Person#lookup you would be looking for Person.all(:conditions = ['first_name LIKE ? OR last_name LIKE ?'],#{params[:value]}%,#{params[:value]}%]) Crude example, but you get the idea... Walter -- 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- t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com . For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en . -- 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- t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en . -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Rails 3 Routes
On May 11, 2011, at 11:00 AM, Chad Eubanks (gMail) wrote: This might be a better example: users/id/posts.json. When user one logs in the related posts are shown. When user two logs in the related posts are shown. However, the id can not be shown in the url. The ID has to be somewhere. So you could be getting it from the session, right? Walter -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Routes - Search url parser
I would advise against a strategy that could ever be ambiguous, even if it looks unlikely at the moment. It would likely bite you at some point in the future, or even worse the developer who comes hereafter, can you imagine what he/she would say about you when he realised the problem and that he would have to do some major reworking? :) Colin Thanks for the advice! For the moment I will use classic way. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] unobtrusive javascript - attaching a .js.erb page
On 9 May 2011 14:30, Sergio Ruiz li...@ruby-forum.com wrote: i saw on one of the railscasts that using unobtrusive javascript, you attach your javascript to your page like so: if your view is: index.html.erb you could add a page named: index.js.erb and that javascript would be included on the load for that page. for some reason, it is not working for me.. is there something i need to do to trigger this behavior? There is no such behaviour in Rails; I think you might have misunderstood the screencast. Assuming you are talking about this: http://asciicasts.com/episodes/205-unobtrusive-javascript then the 'index.js.erb' is rendered when your browser makes an AJAX request to the 'index' action (in the same way that 'index.html.erb' is rendered when your browser makes an ordinary request to the index action). These are two completely separate requests. index.js.erb is *not* being inserted into a script tag in index.html.erb. If you want that kind of thing to happen, you'll need to write a custom view helper (and probably choose a more appropriate path for your automatically-included JavaScript files, so that they don't conflict with the standard behaviour described above). Chris -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Rails 3 Routes
Very true... The session controller would do such. But the question still lingers, does the id NEED to be in the url? Kind Regards, Chad Eubanks Sent from my iPhone On May 11, 2011, at 9:20 AM, Walter Davis wa...@wdstudio.com wrote: On May 11, 2011, at 11:00 AM, Chad Eubanks (gMail) wrote: This might be a better example: users/id/posts.json. When user one logs in the related posts are shown. When user two logs in the related posts are shown. However, the id can not be shown in the url. The ID has to be somewhere. So you could be getting it from the session, right? Walter -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Extending/reopeining class and use of super
A question on a couple things relating to extending a class and the use of super. In my main application I have the following class which extends an engine class: class User ActiveRecord::Base def self.find_for_database_authentication(login_value, omniauth_provider=nil, omniauth_uid=nil) super if login_value where('omniauth_provider=? AND omniauth_uid=?', omniauth_provider, omniauth_uid) end end And the engine has this class: class User ActiveRecord::Base def self.find_for_database_authentication(login_value) where([username = :value OR email = :value, { :value = login_value }]).first end end When I run a spec to try out the method, I get this error: Failure/Error: User.find_for_database_authentication(@user.username).class == User NoMethodError: super: no superclass method `find_for_database_authentication' for #Class:0x1057bbfa0 I do understand why -- my application class is not a subclass of the engine class, I am just extending the class. This leaves me with the question if there is a way to have access to the original method (like using super in a subclass situation) so I would not have to duplicate that code (I would have subclassed my class to the engine class but is a bit nasty as they share the same name, and that is structurally how the app is loaded)? Also, I am confused also as to why I see in places that to extend a class they use MyClass.class_eval do . whereas it seems that if I just do what I have above, I get the same ability. Am I missing something? Anyhow, any comments appreciated! David -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Rails 3 Routes
Not if you're grabbing it from somewhere. The ID MUST be somewhere, or the find will fail. @user = current_user if you're using any sort of common authentication framework. From there, @user.posts is a drop-kick away. Walter On May 11, 2011, at 12:28 PM, Chad Eubanks (gMail) wrote: Very true... The session controller would do such. But the question still lingers, does the id NEED to be in the url? Kind Regards, Chad Eubanks Sent from my iPhone On May 11, 2011, at 9:20 AM, Walter Davis wa...@wdstudio.com wrote: On May 11, 2011, at 11:00 AM, Chad Eubanks (gMail) wrote: This might be a better example: users/id/posts.json. When user one logs in the related posts are shown. When user two logs in the related posts are shown. However, the id can not be shown in the url. The ID has to be somewhere. So you could be getting it from the session, right? Walter -- 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@googlegroups.com . To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en . -- 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- t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en . -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] help with validations
On Wed, May 11, 2011 at 2:36 AM, Quee WM li...@ruby-forum.com wrote: Hi, I am trying to use the new rails 3 validations and running into some issues. for my password I have, validates :password,:presence = {:on = :create}, :length = { :minimum = 5, :maximum = 16 }, :confirmation = true the presence and length are creating problem. I only want to be able to check for the password at create time to confirm if it is present. at update time if someone enters the password it should still match the size limit but it they do not enter the password then it should not be looked at. My sense is that what is tripping things up is that on update and nil password, it is not checking precence but is still checking length and confirmation. It may not be the best way but I tend to use an :if = :method_name, and then in that method check for new_record, etc. in my controller i have already added: params[:user].delete(:password) if params[:user][:password].blank? params[:user].delete(:password_confirmation) if params[:user][:password].blank? and params[:user][:password_confirmation].blank? to take care of any issue coming from that side. any help or suggestion will be greatly appriciated. -- Posted via http://www.ruby-forum.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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Extending/reopeining class and use of super
On 11 May 2011, at 18:17, David Kahn d...@structuralartistry.com wrote: A question on a couple things relating to extending a class and the use of super. In my main application I have the following class which extends an engine class: You are reopening the class (ie adding/changing methods in User), not subclassing it, so super is looking for methods in activerecord::base. Did you want to subclass User instead? Fred class User ActiveRecord::Base def self.find_for_database_authentication(login_value, omniauth_provider=nil, omniauth_uid=nil) super if login_value where('omniauth_provider=? AND omniauth_uid=?', omniauth_provider, omniauth_uid) end end And the engine has this class: class User ActiveRecord::Base def self.find_for_database_authentication(login_value) where([username = :value OR email = :value, { :value = login_value }]).first end end When I run a spec to try out the method, I get this error: Failure/Error: User.find_for_database_authentication(@user.username).class == User NoMethodError: super: no superclass method `find_for_database_authentication' for #Class:0x1057bbfa0 I do understand why -- my application class is not a subclass of the engine class, I am just extending the class. This leaves me with the question if there is a way to have access to the original method (like using super in a subclass situation) so I would not have to duplicate that code (I would have subclassed my class to the engine class but is a bit nasty as they share the same name, and that is structurally how the app is loaded)? Also, I am confused also as to why I see in places that to extend a class they use MyClass.class_eval do . whereas it seems that if I just do what I have above, I get the same ability. Am I missing something? Anyhow, any comments appreciated! David -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Extending/reopeining class and use of super
On Wed, May 11, 2011 at 12:52 PM, Frederick Cheung frederick.che...@gmail.com wrote: On 11 May 2011, at 18:17, David Kahn d...@structuralartistry.com wrote: A question on a couple things relating to extending a class and the use of super. In my main application I have the following class which extends an engine class: You are reopening the class (ie adding/changing methods in User), not subclassing it, so super is looking for methods in activerecord::base. Did you want to subclass User instead? I tried but the thing is that the way the engine loads, the engine class and my class have the same name and reside in the local app. I guess I could give my class a different name to subclass it if I dont want to dup the code. Was just wondering if there was some other way but logically does not seem that there is. Fred class User ActiveRecord::Base def self.find_for_database_authentication(login_value, omniauth_provider=nil, omniauth_uid=nil) super if login_value where('omniauth_provider=? AND omniauth_uid=?', omniauth_provider, omniauth_uid) end end And the engine has this class: class User ActiveRecord::Base def self.find_for_database_authentication(login_value) where([username = :value OR email = :value, { :value = login_value }]).first end end When I run a spec to try out the method, I get this error: Failure/Error: User.find_for_database_authentication(@user.username).class == User NoMethodError: super: no superclass method `find_for_database_authentication' for #Class:0x1057bbfa0 I do understand why -- my application class is not a subclass of the engine class, I am just extending the class. This leaves me with the question if there is a way to have access to the original method (like using super in a subclass situation) so I would not have to duplicate that code (I would have subclassed my class to the engine class but is a bit nasty as they share the same name, and that is structurally how the app is loaded)? Also, I am confused also as to why I see in places that to extend a class they use MyClass.class_eval do . whereas it seems that if I just do what I have above, I get the same ability. Am I missing something? Anyhow, any comments appreciated! David -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: Regex Validation
On Wed, May 11, 2011 at 10:26 AM, Fred Ballard fredb...@gmail.com wrote: +1 to everything Walter has said, as well. I haven't thought about this a lot, but doesn't this apply to everything in terms of user input? Doesn't this really enter the realm of a basic guideline, principle, or law for UI? (I remember something like this being applied to database design.) Don't make people enter data that they don't care about. Don't make people enter data that doesn't affect anything. Carefully evaluate whether people really need to enter data. If people feel free to enter garbage in a field, should that data really be asked for? Aren't there, potentially, corollaries to this? For instance, Always allow the people entering data to easily correct or remove their data. Also, coming from one who has written address validation for credit reporting, you would not believe the complexity --- think of po boxes, boxes, railroad stops, prefixes/suffixes (w,nw,s,...), apartments, suites, rooms I dont remember exactly why I had to do it but it was one of those things I thanked god that I was using tdd :) Fred On Wed, May 11, 2011 at 9:55 AM, Philip Hallstrom phi...@pjkh.com wrote: Walter Im using address to geocoding. Do you know if exists an address check plugin or gem to do this work? Thanks Pedro I repeat my earlier point. If it's not valuable enough to the user, they will spam you like this. If your geocoder reports an error, then raise it to the user, tell him or her sorry, having trouble with that location, could you check the address again? You may be able to find a gem that wraps the USPS database, or FedEx's (with an API key from FedEx, and weeks of back-and-forth with their approval team). But it still gets back to the original value to the user question. What exactly do you give them in return for their successful entry of a real address? Do *they* think it's valuable? +1 for everything Walter has said about requiring it... Also... my memory is that yes the USPS has this ability, but it's not free (and quite expensive). Google can do it as well. Look into the geokit-rails stuff. It won't help with sanitizing the input, but it will turn it into a lat/long pair if it can. If location isn't super super important, just ask for their zip code. That's certainly granular enough to do nearby type functionality. Good luck! -philip Walter On 11 maio, 10:54, Walter Davis wa...@wdstudio.com wrote: I don't think a regex can save you here. Ask yourself a higher-level question. Why are you gathering the address information, and why isn't it optional? If it's to send something of value to the person you're requesting it from by postal mail, or if you're using it to help them find something they need nearby their home, then rest assured they will enter it with care. If it's anything less, you invite this sort of abuse, and you should either just stop asking the question, or realize that a significant percentage of entries will be undeliverable (to use the Post Office's bloodless euphemism). By the way, I believe the USPS has an address checker API, IIRC, I've used it from PHP before, and there may be a Gem wrapper for it as well. Ditto FedEx if you're using them for delivery. Walter On May 11, 2011, at 9:39 AM, Pedro wrote: Hi there, Anybody knows how to use regex to validate street name field? I want to avoid things like st asdkskjfls çsdfksçf. Thanks, Pedro -- 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- t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com . For more options, visit this group athttp:// groups.google.com/group/rubyonrails-talk?hl=en . -- 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@googlegroups.com . To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com.
[Rails] Duplicate method in application_controller and application_helper
I have a method: def current_practice if session[:impersonating] Practice.find session[:impersonating] else current_user.practice end end It is identical in both controller and helper. How could I DRY this up so I only need maintain it in one place? I already have the line helper:all at the top of my ApplicationController, but when I commented out the current_practice in the controller, the one from the helper didn't step in. Maybe I'm misunderstanding what that line is meant to do. Walter -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Running Ruby/Rails Specs with database inserts from non-default spec sub-directory
Hi everyone! I have a question on how to setup my tests a bit differently than the defaults. By default, Rails with RSpec installed provides you with directories such as spec/models, spec/controllers, etc. When i use before(:each), I notice that Rails properly cleans out the database in these specs automatically. However, I created a new sub-directory called spec/queries. My intention was to put all of my query-related tests here so that the database setup code didn't run with the model validation and business logic tests (for speed and organization reasons). I will have a lot of complex queries that will need to be tested against a mini-database... so this seems like the right thing to do (or is there a better solution?) When I put these tests in spec/queries folder and run the tests multiple times, Rails complains that data is not unique and so on... so I am guessing that the data is not getting cleaned out now? Yes, I am using factory girl with sequences, so this is probably a database cleaning problem. I didn't have it before when these same tests were in 'specs/models'. 1. Do I need to manually clean out the data since I moved the specs into it's own spec/squeries subdirectory? 2. Is there any way to include spec/queries to the list of directories that get auto-cleaned, much like spec/models does? Thanks -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Running Ruby/Rails Specs with database inserts from non-default spec sub-directory
On Wed, May 11, 2011 at 1:54 PM, egervari ken.egerv...@gmail.com wrote: Hi everyone! I have a question on how to setup my tests a bit differently than the defaults. By default, Rails with RSpec installed provides you with directories such as spec/models, spec/controllers, etc. When i use before(:each), I notice that Rails properly cleans out the database in these specs automatically. However, I created a new sub-directory called spec/queries. My intention was to put all of my query-related tests here so that the database setup code didn't run with the model validation and business logic tests (for speed and organization reasons). I will have a lot of complex queries that will need to be tested against a mini-database... so this seems like the right thing to do (or is there a better solution?) When I put these tests in spec/queries folder and run the tests multiple times, Rails complains that data is not unique and so on... so I am guessing that the data is not getting cleaned out now? Yes, I am using factory girl with sequences, so this is probably a database cleaning problem. I didn't have it before when these same tests were in 'specs/models'. 1. Do I need to manually clean out the data since I moved the specs into it's own spec/squeries subdirectory? 2. Is there any way to include spec/queries to the list of directories that get auto-cleaned, much like spec/models does? There is a gem called database_cleaner which might help in your case to run before your test/suite. Thanks -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Duplicate method in application_controller and application_helper
Never mind, found helper_method. So now I have helper_method :current_practice in my ApplicationController, and it magically appears in the ApplicationHelper as well. Walter On May 11, 2011, at 2:34 PM, Walter Lee Davis wrote: I have a method: def current_practice if session[:impersonating] Practice.find session[:impersonating] else current_user.practice end end It is identical in both controller and helper. How could I DRY this up so I only need maintain it in one place? I already have the line helper:all at the top of my ApplicationController, but when I commented out the current_practice in the controller, the one from the helper didn't step in. Maybe I'm misunderstanding what that line is meant to do. Walter -- 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- t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en . -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Running Ruby/Rails Specs with database inserts from non-default spec sub-directory
There is a gem called database_cleaner which might help in your case to run before your test/suite. Well, I'm looking into that now... and it mostly works (But not quite... it seems like there are some records hanging around still). Why do I not need the database cleaner for the model tests... but I do for this new spec/queries directory? Can I simply tell rails to treat this directory the same as it treats spec/models? The tests work in that folder. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] [Model Scopes] How to count a nested
Hello, I have a Post that has_many Comments. I have the next scopes: scope :valid, where('created_at = ?', 2.months.ago) scope :expired, where('created_at ?', 2.months.ago) Now, I would have a scope named :commented that return all the Post that have more than 0 Comments but I don't know how do it clearly. A solution is have a counter num_comments column in Post, but I don't know if that is the best practice. Thanks for your advices. Bye. Daniel -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Recurring Billing API Integration w/ SAAS provide, i.e. Cheddargetter
Happy Spring All I need to implement a recurring billing solution w/ API of Cheddargetter. As a ruby nuby, I haven't do any API integration and payment solution before. I watched railscasts about Paypal and active merchant (all in rails 2), however still a bit over my head in terms of what to do in MVC in rails 3. If anyone implemented such API integration w/ cheddargetter, chargify, spreedly, recurly or braintree, can you kindly outline tips about what to do in MVC or your sample code? Your help is greatly appreciated. Linda -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] RVM installation
Hello, after upgrading to ubuntu 11.04 im having this problem with rvm. Im following this tutorial: http://ruby.railstutorial.org/ruby-on-rails-tutorial-book#top Git is installed OK, when I follow the instructions on RVM website aparently its OK too, but when I close my terminal and open a new one and tipe ruby -v ou rvm -v for example I got a messenge rvm is not installed. What should I do? -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Extending/reopeining class and use of super
On May 11, 7:01 pm, David Kahn d...@structuralartistry.com wrote: On Wed, May 11, 2011 at 12:52 PM, Frederick Cheung frederick.che...@gmail.com wrote: On 11 May 2011, at 18:17, David Kahn d...@structuralartistry.com wrote: A question on a couple things relating to extending a class and the use of super. In my main application I have the following class which extends an engine class: You are reopening the class (ie adding/changing methods in User), not subclassing it, so super is looking for methods in activerecord::base. Did you want to subclass User instead? I tried but the thing is that the way the engine loads, the engine class and my class have the same name and reside in the local app. I guess I could give my class a different name to subclass it if I dont want to dup the code. Was just wondering if there was some other way but logically does not seem that there is. You another way is to use alias_method_chain - you'd do something like class Foo class self def something_with_foo end alias_method_chain :something, :foo end end end What this does is rename the existing something method to something_without_foo and renames your something_with_foo method to something. Instead of calling super you call something_without_foo to call the old something_method Fred -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] RVM installation
On 11 May 2011 16:58, Cássio cassiopgodi...@gmail.com wrote: Hello, after upgrading to ubuntu 11.04 im having this problem with rvm. Im following this tutorial: http://ruby.railstutorial.org/ruby-on-rails-tutorial-book#top Git is installed OK, when I follow the instructions on RVM website aparently its OK too, but when I close my terminal and open a new one and tipe ruby -v ou rvm -v for example I got a messenge rvm is not installed. Did you edit .bashrc according to the instructions that should have been shown when you installed rvm? In particular editing the line with return on the end. this is what I do (extracted from my install script) echo now edit .bashrc echo change the line [ -z $PS1 ] return echo to echo if [[ -n $PS1 ]]; then echo and add to the end echo fi echo [[ -s \$HOME/.rvm/scripts/rvm\ ]] source \$HOME/.rvm/scripts/rvm\ echo where the backslashes in above should not be included in edit echo then save it and close and open the terminal echo then rvm notes should show release notes Hopefully it makes sense. Colin What should I do? -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: Extending/reopeining class and use of super
On Wed, May 11, 2011 at 3:29 PM, Frederick Cheung frederick.che...@gmail.com wrote: On May 11, 7:01 pm, David Kahn d...@structuralartistry.com wrote: On Wed, May 11, 2011 at 12:52 PM, Frederick Cheung frederick.che...@gmail.com wrote: On 11 May 2011, at 18:17, David Kahn d...@structuralartistry.com wrote: A question on a couple things relating to extending a class and the use of super. In my main application I have the following class which extends an engine class: You are reopening the class (ie adding/changing methods in User), not subclassing it, so super is looking for methods in activerecord::base. Did you want to subclass User instead? I tried but the thing is that the way the engine loads, the engine class and my class have the same name and reside in the local app. I guess I could give my class a different name to subclass it if I dont want to dup the code. Was just wondering if there was some other way but logically does not seem that there is. You another way is to use alias_method_chain - you'd do something like class Foo class self def something_with_foo end alias_method_chain :something, :foo end end end What this does is rename the existing something method to something_without_foo and renames your something_with_foo method to something. Instead of calling super you call something_without_foo to call the old something_method Oh, that is interesting. I guess which would have be used carefully or could get confusing. This will be fun to play with. Thanks! Fred -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Webrick script/server file does not exist
You are running rails 3. The command to start the server is 'rails server'. On 05/10/2011 11:12 AM, Maria wrote: Hello all, I worked fairly enough with PHP and MySQL, but am very new to Ruby. I have Windows machine with Apache and MySQL installed previously. Both Apache and MySql were stopped while installing Ruby. I tried several ways to install Ruby 1.8.7 and one-step installer. I can use Ruby with netbeans 6.0.1 with its own Ruby or with the one I installed now. The problem starts when I try to create web ruby application. The command C:\Sites rails new helloworld creates the bunch of directories and files: create create README create Rakefile create config.ru create .gitignore create Gemfile create app create app/controllers/application_controller.rb create app/helpers/application_helper.rb create app/mailers create app/models create app/views/layouts/application.html.erb create config create config/routes.rb create config/application.rb create config/environment.rb create config/environments create config/environments/development.rb create config/environments/production.rb create config/environments/test.rb create config/initializers create config/initializers/backtrace_silencers.rb create config/initializers/inflections.rb create config/initializers/mime_types.rb create config/initializers/secret_token.rb create config/initializers/session_store.rb create config/locales create config/locales/en.yml create config/boot.rb create config/database.yml create db create db/seeds.rb create doc create doc/README_FOR_APP create lib create lib/tasks create lib/tasks/.gitkeep create log create log/server.log create log/production.log create log/development.log create log/test.log create public create public/404.html create public/422.html create public/500.html create public/favicon.ico create public/index.html create public/robots.txt create public/images create public/images/rails.png create public/stylesheets create public/stylesheets/.gitkeep create public/javascripts create public/javascripts/application.js create public/javascripts/controls.js create public/javascripts/dragdrop.js create public/javascripts/effects.js create public/javascripts/prototype.js create public/javascripts/rails.js create script create script/rails create test create test/fixtures create test/functional create test/integration create test/performance/browsing_test.rb create test/test_helper.rb create test/unit create tmp create tmp/sessions create tmp/sockets create tmp/cache create tmp/pids create vendor/plugins create vendor/plugins/.gitkeep But as you can see script directory contains only one file rails Here is its content: #!/usr/bin/env ruby.exe # This command will automatically be run when you run rails with Rails 3 gems installed from the root of your application. APP_PATH = File.expand_path('../../config/application', __FILE__) require File.expand_path('../../config/boot', __FILE__) require 'rails/commands' So the command C:\Sites\helloworld\ruby script/server to start WebRick does not work because script/server file does not exist. What do I do wrong? Please help Here is the list of gems: C:\Sitesgem list --local *** LOCAL GEMS *** abstract (1.0.0) actionmailer (3.0.6) actionpack (3.0.6) activemodel (3.0.6) activerecord (3.0.6) activeresource (3.0.6) activesupport (3.0.6) arel (2.0.9) builder (2.1.2) bundler (1.0.12) erubis (2.6.6) i18n (0.5.0) mail (2.2.15) mime-types (1.16) open4 (1.0.1) pg (0.10.1) Platform (0.4.0) polyglot (0.3.1) POpen4 (0.1.4) rack (1.2.2) rack-mount (0.6.14) rack-test (0.5.7) rails (3.0.6) railties (3.0.6) rake (0.8.7) rb-readline (0.4.0) rubyzip2 (2.0.1) sqlite3 (1.3.3 x86-mingw32) sqlite3-ruby (1.3.3) thor (0.14.6) treetop (1.4.9) tzinfo (0.3.26) win32-open3 (0.3.2 x86-mingw32) Thank you in advance. Maria -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] RVM installation
The problem is not Ubuntu. It is rvm. The line that you are suppose to add to your .bashrc has changed: user$ echo '[[ -s $HOME/.rvm/scripts/rvm ]] . $HOME/.rvm/scripts/rvm # Load RVM function' ~/.bash_profile Now you are suppose to run it from a shell. The old way was: [[ -s $HOME/.rvm/scripts/rvm ]] . $HOME/.rvm/scripts/rvm which you add it to your .bashrc file. I had the same stupid problem. On Wed, May 11, 2011 at 11:58 AM, Cássio cassiopgodi...@gmail.com wrote: Hello, after upgrading to ubuntu 11.04 im having this problem with rvm. Im following this tutorial: http://ruby.railstutorial.org/ruby-on-rails-tutorial-book#top Git is installed OK, when I follow the instructions on RVM website aparently its OK too, but when I close my terminal and open a new one and tipe ruby -v ou rvm -v for example I got a messenge rvm is not installed. What should I do? -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] polymorphic and sti problems.
I'm way back at Rails 2.3.5. I can move up to 2.3.11 if anyone thinks that will help. My problem is this: class Entity ActiveRecord::Base belongs_to :item, :polymorphic = true end class Name ActiveRecord::Base has_one :entity, :class_name = Entity, :as = :item end class Team Name end The has_one does not work. It searches for the base_class of item Name instead of the class Team. I see where these is a trick where you can change item_type= in the documentation but that causes me other problems. I tried moving the has_one to Team but that didn't change anything. Any suggestions? -- Posted via http://www.ruby-forum.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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Webrick script/server file does not exist
Thank you very much. I realize it now. Maria On Wed, May 11, 2011 at 5:04 PM, Norm Scherer normsche...@earthlink.netwrote: You are running rails 3. The command to start the server is 'rails server'. On 05/10/2011 11:12 AM, Maria wrote: Hello all, I worked fairly enough with PHP and MySQL, but am very new to Ruby. I have Windows machine with Apache and MySQL installed previously. Both Apache and MySql were stopped while installing Ruby. I tried several ways to install Ruby 1.8.7 and one-step installer. I can use Ruby with netbeans 6.0.1 with its own Ruby or with the one I installed now. The problem starts when I try to create web ruby application. The command C:\Sites rails new helloworld creates the bunch of directories and files: create create README create Rakefile create config.ru create .gitignore create Gemfile create app create app/controllers/application_controller.rb create app/helpers/application_helper.rb create app/mailers create app/models create app/views/layouts/application.html.erb create config create config/routes.rb create config/application.rb create config/environment.rb create config/environments create config/environments/development.rb create config/environments/production.rb create config/environments/test.rb create config/initializers create config/initializers/backtrace_silencers.rb create config/initializers/inflections.rb create config/initializers/mime_types.rb create config/initializers/secret_token.rb create config/initializers/session_store.rb create config/locales create config/locales/en.yml create config/boot.rb create config/database.yml create db create db/seeds.rb create doc create doc/README_FOR_APP create lib create lib/tasks create lib/tasks/.gitkeep create log create log/server.log create log/production.log create log/development.log create log/test.log create public create public/404.html create public/422.html create public/500.html create public/favicon.ico create public/index.html create public/robots.txt create public/images create public/images/rails.png create public/stylesheets create public/stylesheets/.gitkeep create public/javascripts create public/javascripts/application.js create public/javascripts/controls.js create public/javascripts/dragdrop.js create public/javascripts/effects.js create public/javascripts/prototype.js create public/javascripts/rails.js create script create script/rails create test create test/fixtures create test/functional create test/integration create test/performance/browsing_test.rb create test/test_helper.rb create test/unit create tmp create tmp/sessions create tmp/sockets create tmp/cache create tmp/pids create vendor/plugins create vendor/plugins/.gitkeep But as you can see script directory contains only one file rails Here is its content: #!/usr/bin/env ruby.exe # This command will automatically be run when you run rails with Rails 3 gems installed from the root of your application. APP_PATH = File.expand_path('../../config/application', __FILE__) require File.expand_path('../../config/boot', __FILE__) require 'rails/commands' So the command C:\Sites\helloworld\ruby script/server to start WebRick does not work because script/server file does not exist. What do I do wrong? Please help Here is the list of gems: C:\Sitesgem list --local *** LOCAL GEMS *** abstract (1.0.0) actionmailer (3.0.6) actionpack (3.0.6) activemodel (3.0.6) activerecord (3.0.6) activeresource (3.0.6) activesupport (3.0.6) arel (2.0.9) builder (2.1.2) bundler (1.0.12) erubis (2.6.6) i18n (0.5.0) mail (2.2.15) mime-types (1.16) open4 (1.0.1) pg (0.10.1) Platform (0.4.0) polyglot (0.3.1) POpen4 (0.1.4) rack (1.2.2) rack-mount (0.6.14) rack-test (0.5.7) rails (3.0.6) railties (3.0.6) rake (0.8.7) rb-readline (0.4.0) rubyzip2 (2.0.1) sqlite3 (1.3.3 x86-mingw32) sqlite3-ruby (1.3.3) thor (0.14.6) treetop (1.4.9) tzinfo (0.3.26) win32-open3 (0.3.2 x86-mingw32) Thank you in advance. Maria -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: Webrick script/server file does not exist
Thank you very much. I realize it now. Maria On Wed, May 11, 2011 at 4:01 AM, Javix s.camb...@gmail.com wrote: Started from Rails 3, the syntax to start a server is: rails server or shorter: rails s Regards On May 10, 7:12 pm, Maria marajo...@gmail.com wrote: Hello all, I worked fairly enough with PHP and MySQL, but am very new to Ruby. I have Windows machine with Apache and MySQL installed previously. Both Apache and MySql were stopped while installing Ruby. I tried several ways to install Ruby 1.8.7 and one-step installer. I can use Ruby with netbeans 6.0.1 with its own Ruby or with the one I installed now. The problem starts when I try to create web ruby application. The command C:\Sites rails new helloworld creates the bunch of directories and files: create create README create Rakefile create config.ru create .gitignore create Gemfile create app create app/controllers/application_controller.rb create app/helpers/application_helper.rb create app/mailers create app/models create app/views/layouts/application.html.erb create config create config/routes.rb create config/application.rb create config/environment.rb create config/environments create config/environments/development.rb create config/environments/production.rb create config/environments/test.rb create config/initializers create config/initializers/backtrace_silencers.rb create config/initializers/inflections.rb create config/initializers/mime_types.rb create config/initializers/secret_token.rb create config/initializers/session_store.rb create config/locales create config/locales/en.yml create config/boot.rb create config/database.yml create db create db/seeds.rb create doc create doc/README_FOR_APP create lib create lib/tasks create lib/tasks/.gitkeep create log create log/server.log create log/production.log create log/development.log create log/test.log create public create public/404.html create public/422.html create public/500.html create public/favicon.ico create public/index.html create public/robots.txt create public/images create public/images/rails.png create public/stylesheets create public/stylesheets/.gitkeep create public/javascripts create public/javascripts/application.js create public/javascripts/controls.js create public/javascripts/dragdrop.js create public/javascripts/effects.js create public/javascripts/prototype.js create public/javascripts/rails.js create script create script/rails create test create test/fixtures create test/functional create test/integration create test/performance/browsing_test.rb create test/test_helper.rb create test/unit create tmp create tmp/sessions create tmp/sockets create tmp/cache create tmp/pids create vendor/plugins create vendor/plugins/.gitkeep But as you can see script directory contains only one file rails Here is its content: #!/usr/bin/env ruby.exe # This command will automatically be run when you run rails with Rails 3 gems installed from the root of your application. APP_PATH = File.expand_path('../../config/application', __FILE__) require File.expand_path('../../config/boot', __FILE__) require 'rails/commands' So the command C:\Sites\helloworld\ruby script/server to start WebRick does not work because script/server file does not exist. What do I do wrong? Please help Here is the list of gems: C:\Sitesgem list --local *** LOCAL GEMS *** abstract (1.0.0) actionmailer (3.0.6) actionpack (3.0.6) activemodel (3.0.6) activerecord (3.0.6) activeresource (3.0.6) activesupport (3.0.6) arel (2.0.9) builder (2.1.2) bundler (1.0.12) erubis (2.6.6) i18n (0.5.0) mail (2.2.15) mime-types (1.16) open4 (1.0.1) pg (0.10.1) Platform (0.4.0) polyglot (0.3.1) POpen4 (0.1.4) rack (1.2.2) rack-mount (0.6.14) rack-test (0.5.7) rails (3.0.6) railties (3.0.6) rake (0.8.7) rb-readline (0.4.0) rubyzip2 (2.0.1) sqlite3 (1.3.3 x86-mingw32) sqlite3-ruby (1.3.3) thor (0.14.6) treetop (1.4.9) tzinfo (0.3.26) win32-open3 (0.3.2 x86-mingw32) Thank you in advance. Maria -- 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@googlegroups.com. To unsubscribe from
Re: [Rails] Webrick script/server file does not exist
Thank you very much. I realize it now. Maria On Wed, May 11, 2011 at 2:52 AM, Frederick Cheung frederick.che...@gmail.com wrote: On 10 May 2011, at 19:12, Maria marajo...@gmail.com wrote: Hello all, I worked fairly enough with PHP and MySQL, but am very new to Ruby. I have Windows machine with Apache and MySQL installed previously. [snip] But as you can see script directory contains only one file rails The rails command line stuff changed a lot in rails 3, to start the server you now do rails server, to start the console it's rails console etc. Fred Here is its content: #!/usr/bin/env ruby.exe # This command will automatically be run when you run rails with Rails 3 gems installed from the root of your application. APP_PATH = File.expand_path('../../config/application', __FILE__) require File.expand_path('../../config/boot', __FILE__) require 'rails/commands' So the command C:\Sites\helloworld\ruby script/server to start WebRick does not work because script/server file does not exist. What do I do wrong? Please help Here is the list of gems: C:\Sitesgem list --local *** LOCAL GEMS *** abstract (1.0.0) actionmailer (3.0.6) actionpack (3.0.6) activemodel (3.0.6) activerecord (3.0.6) activeresource (3.0.6) activesupport (3.0.6) arel (2.0.9) builder (2.1.2) bundler (1.0.12) erubis (2.6.6) i18n (0.5.0) mail (2.2.15) mime-types (1.16) open4 (1.0.1) pg (0.10.1) Platform (0.4.0) polyglot (0.3.1) POpen4 (0.1.4) rack (1.2.2) rack-mount (0.6.14) rack-test (0.5.7) rails (3.0.6) railties (3.0.6) rake (0.8.7) rb-readline (0.4.0) rubyzip2 (2.0.1) sqlite3 (1.3.3 x86-mingw32) sqlite3-ruby (1.3.3) thor (0.14.6) treetop (1.4.9) tzinfo (0.3.26) win32-open3 (0.3.2 x86-mingw32) Thank you in advance. Maria -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] TypeError: can't convert nil into Integer
I am getting this error with a very simple model and schema. The record saves even though an error has been generated. I have tried this with both postgres and mysql. Here is the model. class Person ActiveRecord::Base end Here is a transcript.. p = Person.new = #Person id: nil, hash: nil, first_name: nil, last_name: nil, middle_name: nil, date_of_birth: nil, date_of_death: nil, age: nil, gender: nil, email: nil, state: 0, status: 0, created_at: nil, updated_at: nil ree-1.8.7-2011.03 :002 p.first_name = 'tim' = tim ree-1.8.7-2011.03 :003 p.save TypeError: can't convert nil into Integer from /home/tim/.rvm/gems/ree-1.8.7-2011.03/gems/activerecord-3.0.5/lib/active_record/connection_adapters/abstract/database_statements.rb:322:in `uniq' from /home/tim/.rvm/gems/ree-1.8.7-2011.03/gems/activerecord-3.0.5/lib/active_record/connection_adapters/abstract/database_statements.rb:322:in `commit_transaction_records' from /home/tim/.rvm/gems/ree-1.8.7-2011.03/gems/activerecord-3.0.5/lib/active_record/connection_adapters/abstract/database_statements.rb:165:in `transaction' from /home/tim/.rvm/gems/ree-1.8.7-2011.03/gems/activerecord-3.0.5/lib/active_record/transactions.rb:207:in `transaction' from /home/tim/.rvm/gems/ree-1.8.7-2011.03/gems/activerecord-3.0.5/lib/active_record/transactions.rb:290:in `with_transaction_returning_status' from /home/tim/.rvm/gems/ree-1.8.7-2011.03/gems/activerecord-3.0.5/lib/active_record/transactions.rb:240:in `save' from /home/tim/.rvm/gems/ree-1.8.7-2011.03/gems/activerecord-3.0.5/lib/active_record/transactions.rb:251:in `rollback_active_record_state!' from /home/tim/.rvm/gems/ree-1.8.7-2011.03/gems/activerecord-3.0.5/lib/active_record/transactions.rb:239:in `save' from (irb):3 ree-1.8.7-2011.03 :004 Person.all = [#Person id: 1, hash: nil, first_name: tim, last_name: nil, middle_name: nil, date_of_birth: nil, date_of_death: nil, age: nil, gender: nil, email: nil, state: 0, status: 0, created_at: 2011-05-12 03:39:33, updated_at: 2011-05-12 03:39:33] ree-1.8.7-2011.03 :005 Here is the SQL statement generated INSERT INTO `people` (`date_of_birth`, `updated_at`, `gender`, `date_of_death`, `created_at`, `hash`, `first_name`, `middle_name`, `age`, `status`, `last_name`, `email`, `state`) VALUES (NULL, '2011-05-12 03:39:33', NULL, NULL, '2011-05-12 03:39:33', NULL, 'tim', NULL, NULL, 0, NULL, NULL, 0) Here is the migration create_table :people do |t| t.string :hash t.string :first_name t.string :last_name t.string :middle_name t.date :date_of_birth t.date :date_of_death t.integer :age t.string :gender t.string :email t.integer :state , :default = 0 t.integer :status , :default = 0 t.timestamps end add_index :people, :email add_index :people, :hash add_index :people, :state add_index :people, :status So there is nothing weird at all. Very strange -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: Call a task when server starts
Can you tell me that how many times the server loads all the files? Because when I start the server it execute the same code multiple times after some period of time. On Wed, May 11, 2011 at 9:46 PM, Tim Shaffer timshaf...@me.com wrote: That actually makes sense. Rails waits for the initializer to finish running before running the rest of your application. So if you have an infinite loop in there, it'll never finish running. Might be best to spawn another process using Thread or just run that code as part of a cron job or other manual process. Would help to understand what your code is trying to do. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.