[Rails] Re: select an existing item or create a new one

2010-04-07 Thread g_f
It sounds like you are looking for something like ActiveRecord's find_or_create_by...() or find_or_initialize_by...() methods. You might look into "Dynamic attribute-based finders" on http://api.rubyonrails.org/classes/ActiveRecord/Base.html -- You received this message because you are subscribe

[Rails] Re: count(*) in find :select returns a String? Why not Fixnum?

2010-04-07 Thread g_f
You might want to try an after_find() or after_initialize() filter for ActiveRecord. If I remember right they'll let you coerce the value to an integer before the object gets returned to the calling code. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails

[Rails] Re: unbalanced brackets error

2010-03-31 Thread g_f
Since you didn't say what the problem was, I'll take a shot at it. It looks like HAML to me. If it is, it looks like you should use the :javascript filter instead of trying to build a

[Rails] Re: Passing parameters to a URL through curl in the application.

2010-03-30 Thread g_f
Search for ruby + libcurl for other suggestions, but patron might do what you want. http://github.com/toland/patron http://www.rubyinside.com/patron-a-simpler-ruby-http-client-2067.html -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To

[Rails] Re: Mechanize

2010-03-24 Thread g_f
I'm not going to create an account to snoop around so you'll need to give more information so we can give better suggestions. Without seeing the HTML for the form and cookies and the URL they send you it's hard to say, however they could be storing a session key in a hidden field or in a cookie. Th

[Rails] Re: nokogiri: parsing tags

2009-11-12 Thread g_f
Use Nokogiri::HTML.fragment(str). On Nov 11, 5:27 am, "Al F." wrote: > Hello, > > I'm trying to use nokogiri gem to parse individual xhtml tags (not the > whole html document) and preform some processing on them. > > Heres an example of a string that I want to process: > > str = ' src="http://

[Rails] Re: Hpricot search

2009-09-07 Thread g_f
What have you written so far and why do you think it didn't work? On Sep 7, 8:43 pm, prashanth hiremath wrote: > I have an html like > > Red<.. > blue... > > I have to write code in such way that i wanna search   text until > > between 2 span Ex: ... --~--~-~--~~

[Rails] Re: querying multiple rows from db in my simple search

2009-08-16 Thread g_f
:conditions => ['body LIKE?' AND 'title LIKE?', "%#{search}%"] Try fixing the condition clause to: :conditions => ['body LIKE ? AND title LIKE ?', "%#{search}%", "%# {search}%" ] You are passing an array containing the SQL "WHERE" clause in a template. Each '?' is a placeholder for th

[Rails] Re: Efficient way to prune a table

2009-08-15 Thread g_f
Doesn't "ORDER BY tstamp" need to be "ORDER BY tstamp DESC"? The latest 10 need to be captured, not the oldest 10. On Aug 14, 10:19 pm, Marnen Laibow-Koser wrote: > RVince wrote: > > Yes, I can see there is no easy, rails-way to do this. In effect, I > > need to > > > 1. read in the X most recen