[Rails] help with validations

2011-05-11 Thread Quee WM
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

[Rails] help with rotues

2011-03-20 Thread Quee WM
in my cities controller I have def for_provinceid @cities = City.where(active = true province_id = ?, params[:id]).sort_by{ |k| k['name'] } respond_to do |format| format.json { render :json = @cities } end end and in my zones controller I have def for_cityid @zones =

[Rails] Re: help with rotues

2011-03-20 Thread Quee WM
must have to as doing http://localhost:3000//cities/for_provinceid/6 gives Routing Error No route matches /cities/for_provinceid/6 -- 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

[Rails] Help with find

2011-03-19 Thread Quee WM
I have the following class Province ActiveRecord::Base has_many :cities attr_accessible :name, :is_active end class City ActiveRecord::Base belongs_to :province attr_accessible :name, :province_id, :is_active end now I want to get all the provinces with is_active = true which have

[Rails] Re: Craiglist and tracking views

2010-01-11 Thread Quee WM
Seems the post was buried and might have gotten off radar. -- 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-t...@googlegroups.com. To unsubscribe

[Rails] reducing the number of if statements

2010-01-09 Thread Quee WM
I have 34 boolean columns in my table related to a product. I need to present this information in a table format with the column header and the corresponding value set to yes or no depending on the boolean value. The end product (i.e. the resulting html code) will be sent as CDATA in an xml feed.

[Rails] Re: reducing the number of if statements

2010-01-09 Thread Quee WM
Conrad Taylor wrote: You can convert the 34 boolean columns to a single binary column. Then you should be able to store, update, and retrieve the individual bits. You might be able to find the following screencast useful: http://railscasts.com/episodes/189-embedded-association Good

[Rails] Re: Craiglist and tracking views

2010-01-09 Thread Quee WM
has anyone had any experience with this? -- 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-t...@googlegroups.com. To unsubscribe from this group, send

[Rails] Re: Craiglist and tracking views

2010-01-09 Thread Quee WM
Marnen Laibow-Koser wrote: Huh? You can put links in Craigslist postings. What's the problem? Craiglist block any ad with a bit.lu link in it and says it violates the terms of use. Are you trying to track views of your Craigslist ad? If so, that's a different problem than bit.ly, and

[Rails] Craiglist and tracking views

2010-01-08 Thread Quee WM
well I got done with finally getting a bitly link for each of my products and now I learn that craiglist does not support something like bitly in the posting. I have come across the idea of using a 1x1 image to track the views but the issue I am facing now is where this data will be stored in my

[Rails] Re: how do I get the host or Ip address where my rails app i

2010-01-08 Thread Quee WM
Mark Reginald James wrote: You can try require 'socket' REAL_PRODUCTION = Socket.gethostname == 'mysite.com' or hostinfo = Socket.gethostbyname(Socket.gethostname) hostnames = hostinfo[1] hostinfo[0] REAL_PRODUCTION = hostnames.include?('mysite.com') -- Rails Wheels - Find

[Rails] Re: how do I get the host or Ip address where my rails app i

2010-01-08 Thread Quee WM
Thanks Sijo. This will help a lot. Sijo k g wrote: Hi Kad Kerforn require 'ipaddr' require 'net/http' def get_ip con = Net::HTTP.new('checkip.dyndns.org', 80) resp,body = con.get(/, nil) ip = body.match(/\d+\.\d+\.\d+\.\d+/) ip[0] end my_ip = IPAddr.new(get_ip) -- Posted via

[Rails] Re: Re: Updating table data

2010-01-07 Thread Quee WM
Your Rails app classes are accessible in migrations, so you can call the bit.ly link generator just like you would from the application itself. Thanks for the info, did not know this before. At this point, stop asking questions and go write some migration code. If you run into trouble,

[Rails] Updating table data

2010-01-06 Thread Quee WM
I have an application in rails in which i am adding a new column in one of the tables. The value for the new column is a bit.ly link and I need to populate this for each record in the table approx. 250 rows will be affected. Q1: Can this be done outside the application? i.e. write a script that

[Rails] Re: Re: Updating table data

2010-01-06 Thread Quee WM
Aldric Giacomoni wrote: That is true - but since he mentioned a bit.ly link, I thought it would be different for every row. You are 100% right that it will be different for each row. With the help of others on this forum I have written a callback function which provides me with a bitly link

[Rails] Re: Re: Updating table data

2010-01-06 Thread Quee WM
Also I posted the same question on the ruby forum and one suggestion so far is that For one-shot scripts that are not exactly migrations, it should be an acceptable way to use an external script. I find some weight in this as well as what if I need to redeploy the same app on a new server,

[Rails] Re: add external data at new record creation time

2010-01-05 Thread Quee WM
Back for some more help. I added the following code to the model of the vehicle class Vehicle ActiveRecord::Base after_save :update_bit_ly_url def update_bit_ly_url bit_ly_url = CreateUri::bit_ly_for_vehicle(self.id) puts bit_ly_url end end had to change CreateUri. to

[Rails] Re: to_parm and how it can be used in a helper

2010-01-05 Thread Quee WM
Rein Henrichs wrote: It can be accomplished by calling the to_param (not to_parm) method on the object in question. For instance, @city.to_param, where @city is a City object. Thanks for the information. That solved one of my problems. :) -- Posted via http://www.ruby-forum.com/. -- You

[Rails] add external data at new record creation time

2010-01-04 Thread Quee WM
In my project i require a bit.ly link for each new product entered in the database. Please guide me on how to do this? Note: I am using a standard rails app with basic actions to test this code I plan on writing a helper function which will be able to take the id for the new record and return

[Rails] to_parm and how it can be used in a helper

2010-01-04 Thread Quee WM
is there a way to pass the data returned by the to_parm function in a helper? i followed the info provided at http://www.jroller.com/obie/entry/seo_optimization_of_urls_in and am able to successfully get the correct urls, now i want to be able to get the same (id-whatever) text and pass it to a

[Rails] not being able to access the info loaded by config.yml

2010-01-04 Thread Quee WM
Hi, I have the following app_config.yml in rails_root/config/ development: non_production_settings :bit_ly: :login: x :api_key: x :history: 0 test: : *non_production_settings production: :bit_ly:APP_CONFIG = YAML.load(File.read(RAILS_ROOT +

[Rails] Re: add external data at new record creation time

2010-01-04 Thread Quee WM
Thanks for the help. That put me on the right path. -- 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-t...@googlegroups.com. To unsubscribe from this

[Rails] Re: not being able to access the info loaded by config.yml

2010-01-04 Thread Quee WM
I think yaml keys need to be strings, not symbols, i.e. that would read: development: bit_ly: login: something api_key: secret history: 0 Felix Well I followed the info provided here:

[Rails] Re: Help with routes

2010-01-01 Thread Quee WM
Worked like a charm. Thanks. Bruno Grasselli wrote: Try: map.resources :feeds, :collection = {:xml = :get, :csv = :get} -- 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,