[Rails] How do I stop email from being delivered in the interceptor?

2011-02-28 Thread Sam Kong
Hi, I am developing a rails 3 application. I want to use a interceptor before delivering emails. If a conditions meets, I want to stop the email. How do I do that? Thanks. Sam -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Grou

[Rails] ActionMailer: hostname was not match with the server certificate

2011-02-18 Thread Sam Kong
Hi, I am setting up SMTP for my Rails 3 App. This configuration works. ActionMailer::Base.delivery_method = :smtp ActionMailer::Base.smtp_settings = { :address => "smtp.gmail.com", :port => 587, :domain => "mydomain.com", :user_name=

[Rails] Is this a bug of accepts_nested_attributes_for ?

2011-01-26 Thread Sam Kong
Hi, I've been digging a bug for 3 days. I pin-pointed the problem line of codes. It's not my code but the activerecord code. The problem is with the activerecord-3.0.3/lib/active_record/nested_attributes.rb line# 376: association.send(:add_record_to_target_with_callbacks, existing_record) if !as

[Rails] Question about accepts_nested_attributes_for and reject_if

2011-01-24 Thread Sam Kong
Hi, I am developing a rails 3.0.3 application and accepts_nested_attributes_for method is giving me pains. To simplify the issue, I created a new app and generated 2 models. users name: string cars -- user_id: integer name: string class User < ActiveRecord::Base has_many :cars

[Rails] Weird Rails 3 Route Problem

2011-01-10 Thread Sam Kong
Hi, I am using simple_captcha. It worked find until I add the following line to routes.rb match ":controller(/:action)", :constraints => {:controller => /sandbox\/[^\/]+/} The captcha image is not showing and the log shows the following error message. Started GET "/simple_captcha/8cdf70c193dc88

[Rails] Relay Access Denied

2010-11-26 Thread Sam Kong
Hi, I have several rails applications on a shared hosting. To avoid the server's restriction of sending mails, I use an external SMTP. It works most of times but for some sender emails it gives an error. Net::SMTPFatalError (554 5.7.1 : Relay access denied The error happens if sender's domain i

[Rails] passenger for both rails 2.3 and 3.0

2010-10-27 Thread Sam Kong
Hi, I installed ruby 1.8.7 and passenger 3.0 for apache2 on Ubuntu 10.10. Rails 2.3 works fine. But Rails 3.0 gives an error saying that rack version is not 1.2.1. If I upgrade the rack to 1.2.1, then rails 2.3 app complains that the rack version is not ~>1.1.0. How do I satisfy both rails 2.3 an

[Rails] Where can I find the full document for rails application template?

2010-10-24 Thread Sam Kong
Hi, I am trying to learn how to use rails application template (as in "rails new app_name -m "). I can find some examples but I can't find full document for the APIs. Does anyone know where the document is? Thanks. Sam -- Posted via http://www.ruby-forum.com/. -- You received this message be

[Rails] Passenger is not working

2010-10-22 Thread Sam Kong
Hi, I just installed passenger 3.0.(on rvm system, using sudo). Strangely, gem path was not found. So I did "sudo /var/lib/gems/1.8/bin/passenger-install-apache2-module". Installation process was smooth. I modified httpd.conf and added myapp.local configuration and modified hosts for the local dom

[Rails] Problem while installing passenger for apache

2010-10-18 Thread Sam Kong
Hi, I am trying to install passenger 3.0 for apache2 on Ubuntu 10.10. It says that I need to install libopenssl-ruby. But when I did 'sudo apt-get install libopenssl-ruby', I got the following error. Reading package lists... Done Building dependency tree Reading state information... Done Note,

[Rails] gvim error with rails.vim

2010-10-15 Thread Sam Kong
Hi, I just installed Ubuntu 10.10 and vim 7.2.330. I Use rails.vim and set it auto-start when pwd is rails directory. vim works find. However, gvim gives errors. "Error detected while processing function 18_menuBufEnter. E117: Unknown function rails#app E15: Invalid expression: rails#app... And

[Rails] When to use 'bundle package'

2010-09-01 Thread Sam Kong
Hi, If you do 'bundle install vendor', gems will be installed in the application. Then, you can deploy it to your production server. When do you need to do 'bundle package'? If you do 'bundle package', the gem files will be in vendor/cache. Do you normally add vendor/cache to your git repository?

[Rails] Rails 3 routing for namespaced controllers

2010-08-23 Thread Sam Kong
Hi, I need to use legacy-style routing. And it's namespaced. According to http://edgeguides.rubyonrails.org/routing.html, it should be like the following. match ':controller(/:action(/:id))', :controller => /admin\/[^\/]+/ /admin/c1/a1 works fine. But the problem is that, if I have /c2/a2 (not

[Rails] Re: Re: Re: Re: What's the best way to solve this?

2010-08-16 Thread Sam Kong
Hassan Schroeder wrote: > On Mon, Aug 16, 2010 at 10:19 AM, Sam Kong wrote: > >> Our top menus are categories. >> I need to highlight the category. >> Do you have any good idea for that? > > Well, some choices are to "highlight" > > 1) none of the

[Rails] Re: Re: Re: What's the best way to solve this?

2010-08-16 Thread Sam Kong
Hassan Schroeder wrote: > On Mon, Aug 16, 2010 at 10:02 AM, Sam Kong wrote: > >> The problem is that @product.categories is multiple. >> I need to highlight only 1 category for the product and show only 1 >> breadcrumb. >> If there's some path that the user

[Rails] Re: Re: What's the best way to solve this?

2010-08-16 Thread Sam Kong
Colin Law wrote: > On 16 August 2010 17:10, Sam Kong wrote: >>> category. >> >> Sorry. >> I was not clear about this. >> Product and Category are m:n relationship. >> Actually there's a Categoryship model. > > It would be easier if you co

[Rails] Re: What's the best way to solve this?

2010-08-16 Thread Sam Kong
Colin Law wrote: > On 16 August 2010 06:05, Sam Kong wrote: >> Hi, >> >> Here's a situation: >> A product belongs to multiple categories and the categories are top >> menus of a site. > > That does not make sense, do you mean product has_many ca

[Rails] What's the best way to solve this?

2010-08-15 Thread Sam Kong
Hi, Here's a situation: A product belongs to multiple categories and the categories are top menus of a site. I want to highlight the category of a product when the product detail page is loaded. If there's some context, I can determine which category should be highlighted. (For example, I can trac

[Rails] Best way to render partial

2010-08-15 Thread Sam Kong
Hi, I wonder which is better between [1] and [2]. [1] --layouts/application.html.erb ... <%= yield %> ... ---some_action.html.erb ... Page title Some contents... ... [2] --layouts/application.html.erb ... <%= yield %> ... ---some_action.html.erb-

[Rails] Re: Passenger can't find rails gem

2010-07-24 Thread Sam Kong
Sam Kong wrote: > rholmes wrote: >> I fixed this on my machine as follows: >> >> The boot.rb file is the one that was generating this message, in a >> method called 'load_rails_gem'. If you print the value of the >> variable 'load_error' it wi

[Rails] Re: Passenger can't find rails gem

2010-07-24 Thread Sam Kong
rholmes wrote: > I fixed this on my machine as follows: > > The boot.rb file is the one that was generating this message, in a > method called 'load_rails_gem'. If you print the value of the > variable 'load_error' it will give you a specific error message as to > why the gem wouldn't load. In m

[Rails] Re: Passenger can't find rails gem

2010-07-07 Thread Sam Kong
Leonardo Mateo wrote: > On Wed, Jul 7, 2010 at 7:21 AM, Sam Kong wrote: >> Could not find gem 'rails (= 3.0.0.beta4, runtime)' in the gems >> PassengerRuby /Users/ssk/.rvm/rubies/ruby-1.8.7-p299/bin/ruby >> >> >> Why can't passenger find rails? &

[Rails] Passenger can't find rails gem

2010-07-07 Thread Sam Kong
Hi, I installed rvm on my OS X Snow Leopard. And I installed ruby 1.8.7 and gemset rails3. I also installed passenger. My rails app runs find with 'rails server'. However it doesn't run on passenger. Error message is: Could not find gem 'rails (= 3.0.0.beta4, runtime)' in the gems available on t

[Rails] Re: How do I upgrade rack in my current rails app?

2010-06-14 Thread Sam Kong
Robert Walker wrote: > Sam Kong wrote: >> I have a rails 2.3.8 app which has rack 1.1.0. >> I get parse_multipart error. >> There's a new release of rack 1.2.0 which might fix the multipart error. >> >> The question is how I upgrade the rack? >> I fro

[Rails] How do I upgrade rack in my current rails app?

2010-06-14 Thread Sam Kong
Hi, I have a rails 2.3.8 app which has rack 1.1.0. I get parse_multipart error. There's a new release of rack 1.2.0 which might fix the multipart error. The question is how I upgrade the rack? I froze the rails. I did "gem update rack" and it upgraded rack to 1.2.0. But my rails app still uses ra

[Rails] Rack error: bad body content

2010-05-28 Thread Sam Kong
Hi, I get an error like the following. /!\ FAILSAFE /!\ 05/27/2010 12:50 Status: 500 Internal Server Error bad content body /usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/utils.rb:319:in `parse_multipart' It happens when I update a page with images. This doesn't happen on development s

[Rails] What does attachment_fu do when saving?

2010-05-22 Thread Sam Kong
Hi, I have a model with attachment_fu. The model saves images but I didn't put validates_as_attachment. I understand that it takes long time to create an object as it has to process images. But I don't understand why it takes long time to update the object (not changing file but only modify other

[Rails] attachment_fu slows down update

2010-05-20 Thread Sam Kong
Hi, I use attachment_fu and it slows down update. [Models] product has many pictures. [Update] product.update_attributes("pictures_attributes"=>{ "6"=>{"_delete"=>"0", "color_id"=>"3", "id"=>"2953"}, "11"=>{"_delete"=>"0", "color_id"=>"9", "id"=>"2921"}, "22"=>{"_delete"=>"0", "color_id"=>"24",

[Rails] I cannot install Rails 3.0 on my OS X

2010-05-16 Thread Sam Kong
Hi, I've upgraded ruby to 1.8.7. But when I tried to install rails 3.0, it said that I need ruby 1.8.7 or higher. ruby-1.8.7-p248$ ruby -v ruby 1.8.7 (2009-12-24 patchlevel 248) [i686-darwin9.8.0] ruby-1.8.7-p248$ sudo gem install rails --pre ERROR: Error installing rails: activesupport requir

[Rails] attachment_fu generates wrong public_filename

2009-10-06 Thread Sam Kong
Hi, attachment_fu generates wrong public_filename. >> pic.thumbnails => ProductPicture id: 12331, product_id: nil, parent_id: 12330, content_type: "image/png", filename: "b_9788994035109_mid.png", thumbnail: "mid", size: 16562, width: 205, height: 205, created_at: "2009-10-05 02:43:50", updated_

[Rails] Passenger 2.2.2 error

2009-06-22 Thread Sam Kong
Hi, I deployed an rails 2.3.2 app on passenger 2.2.2. I get the following error sometimes. Is it something I can fix in my app or not? Passenger encountered the following error: The application spawner server exited unexpectedly: Broken pipe Exception class: PhusionPassenger::Railz::Application

[Rails] Recursive partial wasted my 2 hours

2009-06-11 Thread Sam Kong
Hi, When I called a page, the server choked like frozen. I checked it with 'top' command and HDD(wa) was 95%. There's no error or suspicious log. After wasting 2 hours, I found that a partial called it self. In _a.html.erb <%= render :partial => "a" %> Can rails detect such a mistake and stop p

[Rails] Re: Passenger 2.2.1 error?

2009-05-04 Thread Sam Kong
Sam Kong wrote: > Hi, > > I am running my rails 2.3.2 app on Passenger 2.2.1. > > There's a simple page like > > render :text => "Hello" > > > And it crashes about every 1 out of 5 refreshes. > > Is there any known issue with Passenge

[Rails] Passenger 2.2.1 error?

2009-05-04 Thread Sam Kong
Hi, I am running my rails 2.3.2 app on Passenger 2.2.1. There's a simple page like render :text => "Hello" And it crashes about every 1 out of 5 refreshes. Is there any known issue with Passenger 2.2.1? Thanks. Sam -- Posted via http://www.ruby-forum.com/. --~--~-~--~~---

[Rails] Re: Restful_authentication doesn't work in Rails 2.3.2

2009-05-01 Thread Sam Kong
Matt Jones wrote: > Yep, you're seeing an incompatibility - I think 2.1.2 was the first > version of Passenger that worked with Rails 2.3.2. > > --Matt Jones Yes, you're right. I complained to DreamHost and surprisingly they moved my account to a newer server which has Passenger 2.2.1. Thanks

[Rails] Restful_authentication doesn't work in Rails 2.3.2

2009-04-30 Thread Sam Kong
Hi, I'm using restful_authentication on rails 2.3.2. It works find on my local machine which has passenger 2.1.2. But it doesn't work on the web hosting server (DreamHost) which may have lower version of passenger. The problem is session[:user_id] is not reserved while redirecting. Is this an in

[Rails] tiny_mce and jquery + jrails

2009-04-29 Thread Sam Kong
Hi, I've been using tiny_mce_plus. Recently I changed prototype to jquery and jrails. It caused problems to tiny_mce_plus. So I replaced the prototype.js part in tiny_mce_plus with jquery and jrails. But according to log, the tiny_mce still uses prototype.js even if I restarted rails app. I grep

[Rails] compromising development mode and production mode

2009-04-08 Thread Sam Kong
Hi, I have a very stupid question. I run my rails application on phusion passenger. As you know, in production mode I need to 'touch tmp/restart.txt' when I've changed some files. In development mode, it's not needed. Can I run the production mode application like it's development mode so that

[Rails] Re: IE's session id changes on every request

2008-11-13 Thread Sam Kong
Sam Kong wrote: > Hi, > > I am developing a site with rails 2.1.2. > restful_authentication is used. > > I can log in with Firefox but not with IE or Safari. > I checked the log and found that session ID changes every time for IE. > > Why does this happen? > &

[Rails] IE's session id changes on every request

2008-11-13 Thread Sam Kong
Hi, I am developing a site with rails 2.1.2. restful_authentication is used. I can log in with Firefox but not with IE or Safari. I checked the log and found that session ID changes every time for IE. Why does this happen? Thanks. Sam -- Posted via http://www.ruby-forum.com/. --~--~

[Rails] Sharing view between new and edit actions

2008-11-12 Thread Sam Kong
Hi, I had an argument with the web designer about a philosophical(not very practical) issue. Normally, we have new.html.erb and edit.html.erb and they share _form.html.erb as a partial render. The designer said that there should be only one view template and use if-statement for minor difference

[Rails] Re: InvalidAuthenticityToken error only in IE

2008-11-12 Thread Sam Kong
Mike wrote: > Hi, > i've got the same problem. i cant find any fix for it neither can i > reproduce it. it just "sometimes" works. > Mike Thanks for the reply. I couldn't fix it. I just disabled forgery protection. :-( Sam -- Posted via http://www.ruby-forum.com/. --~--~-~--~~

[Rails] InvalidAuthenticityToken error only in IE

2008-11-11 Thread Sam Kong
Hi, I am developing a web site using rails 2.1.2. I'm using restful_authentication. I get InvalidAuthenticityToken error at login in IE & Safari. Firefox works fine. What's wrong? Thanks. Sam Full trace: vendor/rails/actionpack/lib/action_controller/request_forgery_protection.rb:86:in `verif

[Rails] Re: auto-complete without connecting to the server

2008-11-05 Thread Sam Kong
Robert Zotter wrote: > Take a look at the local autocompleter wiki, it has all the > information you will need. > http://github.com/madrobby/scriptaculous/wikis/autocompleter-local Thank you very much. This is exactly what I was looking for. Sam -- Posted via http://www.ruby-forum.com/. --~-

[Rails] auto-complete without connecting to the server

2008-11-05 Thread Sam Kong
Hi, My client wants to type instead of select from a list. But it's not just a free typing but typing the first few letters. So basically, it's auto-complete function except that the list data is already in the client as an array in JavaScript. Is there any plugin for such a function? If not, ho