[Rails] how to save one value into the attributes of all rows in a model

2009-04-09 Thread tyliong
When i use Model.all and i want to save this one value into all the rows of the model how do i do it without using a "for" loop. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to

[Rails] Getting the top results only by group in a .find statement

2009-04-08 Thread tyliong
This is my table model name is bids id | bid | keyword 1 | 2 | orange 2 | 3 | orange 3 | 1 | red 4 | 3 | blue 5 | 6 | red what i want is the get these the top bidder of each unique keyword in one .find statement --~--~-~--~~~---~--~~ You rec

[Rails] /lib daemon folder: how do i add a module into the daemon?

2009-04-06 Thread tyliong
I am using the daemons plugin. I have just one problem how do i add modules from the /lib folder to the /lib/daemons/daemon.rb file eg. /lib/basic_functions.rb this is the file i want to load in daemon.rb contents daemon.rb: #!/usr/bin/env ruby # You might want to change this ENV["RAILS_ENV"

[Rails] SMTP settings for action mailer

2009-01-08 Thread tyliong
with rails 2.2.2 action mailer requires a valid ssl certificate i have a question about routing my smtp settings for my postfix are now ActionMailer::Base.smtp_settings = { :address => "smtp.mydomain.com", :port => 25, :domain => "mydomain.com", :authentication => :plain, :user_name => "mydomain

[Rails] Actionmailer and postfix settings

2009-01-07 Thread tyliong
Hi, I am having problems configuring my actionmailer to work with postfix. I followed this tutorial: http://howtoforge.org/virtual-users-and-domains-postfix-courier-mysql-centos5.1 and i got the server set up. at first i fixed the mail settings to work with gmail using this tutorial: http://

[Rails] serializing active record objects do not save after first slice

2008-12-18 Thread tyliong
Hi, i am having a very weird problem i have an array Model: serialize :marketarray Controller @marketobject = Market.find(1) @marketobject.marketarray = ["red","blue","green"] I do this @marketobject.marketarray.slice!(0) @marketobject.save! but it does not change the Market.marketarray t

[Rails] select_tag and select_date how to change inline font

2008-12-12 Thread tyliong
I have been trying to change the font size in the select_date but i haven't had any luck here's what i did: <%= select_date( Date.today, :prefix => 'prom_date_end', :order => [ :day,:month, :year], :html => {:style => "font-size: xx-small;"}) %> --~--~-~--~~~---~--~--

[Rails] Validation errrors: how to get rid of "Validation failed: " and the Objects in them

2008-12-09 Thread tyliong
Hi when ever i do rescue Exception => e flash[:error] = e.message the e.message will always contain the "Validation error:" string and the Object Example: Validation failed: Price "message:", Price "message" How do i tell rails that I just want the message? and

[Rails] Active record :find having an if statement inside the conditions

2008-12-09 Thread tyliong
Hi, i was just wondering if its is possible to put a if statment inside the find conditions for example: grovery_price = model.find(:first, :conditions => [ "if x = ? then y must = ?", 200, 300] I have been googling for some time for a solution to this but i just can't seem to find any. --~--~

[Rails] Find active record condition of not equal

2008-12-07 Thread tyliong
Hi, I have tried creating a not equal condition in the find statment but it just outputs an empty array. model.find(:first, :conditions => [" id = ? AND market = ? AND promotion <> ? " , id , name, "y"],:order => 'id desc').price I have tried != instead of <> I have tried googling for the answ

[Rails] Ajax on failure message

2008-11-14 Thread tyliong
How do i change the ajax failure message <% remote_form_for(:comment, :url => grocery_comments_path(params [:id]), :html => { :id => 'new_comment_form' }, :method => :post, :update => { :failure => "error" }) do |form| %> the :update => { :failure => "error" } gives me the usual error m

[Rails] Re: form.text_area, how do you empty its contents?

2008-10-31 Thread tyliong
Never mind i got it @comment.body = "" before the page.replace On Nov 1, 1:34 am, tyliong <[EMAIL PROTECTED]> wrote: > Hi, after i click submit and refresh the parital(with > page.replace_html) with the remote_form_for, the <%= > form.text_area :body, :rows => 10

[Rails] form.text_area, how do you empty its contents?

2008-10-31 Thread tyliong
Hi, after i click submit and refresh the parital(with page.replace_html) with the remote_form_for, the <%= form.text_area :body, :rows => 10, :cols => 40 %> still contains the previous text. how do i totally remove the text inside of it? --~--~-~--~~~---~--~~ You re

[Rails] Passing a function with arguments to another function with arguments that is a loop

2008-10-28 Thread tyliong
Hi, I am a noobie. I just want to know what is the standard or most effective way of doing this I have two functions def display_price(grocery,batch) grocery_price = grocery.send(batch).price if grocery_price number_to_currency(gro

[Rails] Re: protect_from_forgery :only => [:create, :delete, :update] what does this do exactly?

2008-10-07 Thread tyliong
ke > > > Sent: Wednesday, August 27, 2008 10:18 PM > > > To: Ruby on Rails: Talk > > > Subject: [Rails] Re: protect_from_forgery :only => [:create, :delete, > > > :update] what does this do exactly? > > > > (3)If it is that good should i use i

[Rails] Re: Need help with AJAX partial not refreshing browser asking to save .js instead

2008-09-23 Thread tyliong
never mind i solved it On Sep 23, 4:46 pm, tyliong <[EMAIL PROTECTED]> wrote: > Hi, when i use the updatepassword action, it does not refresh the ajax > partial but forces the browser to save a file > why does that happen? > > def updatepassword >                 @user =

[Rails] Need help with AJAX partial not refreshing browser asking to save .js instead

2008-09-23 Thread tyliong
Hi, when i use the updatepassword action, it does not refresh the ajax partial but forces the browser to save a file why does that happen? def updatepassword @user = current_user return unless request.post? if User.authenticate(current_user.login, params[:old_password])

[Rails] Re: Seriously stumped cannot call attribute out

2008-09-07 Thread tyliong
(irb):30 On Sep 7, 11:14 pm, tyliong <[EMAIL PROTECTED]> wrote: > Hi, i am having problems displaying a simple attribute. what is weird > is that all the other attributes are can be called but not .p  . I > have been racking my brain on why but I just don't get it. it doesn&#

[Rails] Seriously stumped cannot call attribute out

2008-09-07 Thread tyliong
Hi, i am having problems displaying a simple attribute. what is weird is that all the other attributes are can be called but not .p . I have been racking my brain on why but I just don't get it. it doesn't make sense i can call nearly every attribute except this one DB creation code: creat

[Rails] Re: nested array .select statment

2008-09-06 Thread tyliong
undefined method `[]' for # meaning that theres something wrong with groceries.price but in the migration file .price is specified to be t.decimal :price, :precision => 8, :scale => 2 I don't understand why rails is giving an undefined method when i subsitute in decimals for 1 and

[Rails] nested array .select statment

2008-09-06 Thread tyliong
Hi! the array is like this [[1,"h"],[2,"g"]] i want to select the parts of the array with the minimum value and show the 2nd part of the element only meaning the strings like "h" and "g" i've tried this but it doesn't work x.select{|c| c.first = [x.min{|a,b| a.first <=> b}.first]}.last and i ge

[Rails] Re: nested array minimum

2008-09-06 Thread tyliong
solved On Sep 6, 4:16 pm, tyliong <[EMAIL PROTECTED]> wrote: > Hi, > > usually when i do this: > > x = [1,2,3,] > > result = x.min > > but let's say I have a nested array > > x = [ [1,"h"], [2,"c"]] &g

[Rails] nested array minimum

2008-09-06 Thread tyliong
Hi, usually when i do this: x = [1,2,3,] result = x.min but let's say I have a nested array x = [ [1,"h"], [2,"c"]] how to i just display the min value (1) and its pair value "h" --~--~-~--~~~---~--~~ You received this message because you are subscribed to t