[Rails] Helper

2009-02-20 Thread James Bond
How make a helper: If value X is true: print li class=current else li -- 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,

[Rails] Re: Helper

2009-02-20 Thread James Bond
Andrew Bloom wrote: def current_li(content, x) klass = x ? current : nil content_tag(:li, content, :class = klass) end Thanks, but why this doesn't work? %= current_li {link_to xxx, :controller = yyy}, @x == 1 % -- Posted via http://www.ruby-forum.com/.

[Rails] Re: Active Record Associations

2009-02-11 Thread James Bond
How can I find all users whose name is James% and their computers (not mobiles)? User.find(:all, ??) Help ??? -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups

[Rails] Re: Active Record Associations

2009-02-11 Thread James Bond
Sijo Kg wrote: I mean something like this: SELECT users.name, computers.name FROM users, OwnComputers, computers JOIN OwnComputers ON users.id = OwnComputers.users_id JOIN computers ON OwnComputers.computers_id = computers.id WHERE user.name LIKE James% -- Posted via

[Rails] ThroughAssociations

2009-02-11 Thread James Bond
There is example: http://wiki.rubyonrails.org/rails/pages/ThroughAssociations Example Catalogue has_many :catalogue_items CatalogueItems belongs_to :catalogue; belongs_to :product Product has_many :catalogue_items So how I can get: catalogues.name catalogue_items.position products.name

[Rails] Re: ThroughAssociations

2009-02-11 Thread James Bond
Catalogue has_many :catalogue_items, :order = position Thanks, but if I want sot like: :order = catalogues.name!='#...@name}', catalogues.name, products.name Where @name is serarch word. -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You

[Rails] Re: ThroughAssociations

2009-02-11 Thread James Bond
Can you explain, in english as opposed to code, what it is that you ultimately want to do? Sorry. Search way I use is: match(catalogues.name) against xxx And order by is (catalogues.name, products.name) But first where catalogues.name == xxx Example If catalogues.names are: aaa xxx,

[Rails] Re: ThroughAssociations

2009-02-11 Thread James Bond
It is hard explain without example. I need Full-Text Search SELECT * FROM products WHERE MATCH(name) AGAINST('lamp') ORDER BY name Returns: alarm lamp lamp trouble lamp wall lamp But: SELECT * FROM products WHERE MATCH(name) AGAINST('lamp') ORDER BY name!='lamp', name Returns: lamp alarm

[Rails] Active Record Associations

2009-02-10 Thread James Bond
I have tables: users (id, name) computers (id, name) mobiltelefons (id, name) OwnComputers (id, user_id, computer_id) OwnMobiltelefons (id, user_id, mobiltelefon_id) So is it has_many :through or has_and_belongs_to_many or what? I only need to search one own table at time: All computers that

[Rails] Re: Active Record Associations

2009-02-10 Thread James Bond
Rey wrote: If I understand correctly what you need, a computer may belong to many users and one user can have many computer, right? same for phones, I assume. Yes In this case, the relationship is :has_and_belongs_to_many, but you do How can I find all users whose name is James% and

[Rails] Database table name in array?

2009-01-30 Thread James Bond
Is it possible to do something like this? tables = Array[ Xxx, Yyy, Zzz] for table in tables results = table.find(:all, :conditions = [. end -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are

[Rails] Auto complete form

2009-01-30 Thread James Bond
If I have table user (id, firstname, lastname, age, city) And form: textboxes for firstname, lastname, age and select for city Is it possible to auto complete form? Not only firstname or lastname, but full form? So if I enter lastname, and there is only one user with this name, so it auto

[Rails] Right way to do

2009-01-27 Thread James Bond
What is the right way to print localizations? %=t :User % OR %=t User % OR %=t (User) % %=t :User % works fine, but %=t :User.Username % doesn't, but this works: %=t (User.Username) % -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received

[Rails] Relationships in Rails...

2009-01-26 Thread James Bond
I have 2 tables: people (id, name) children (id, parents_id, child_id) parents_id = people.id and child_id = people_id also So how I make a relationships in Rails? And how can all search: Children.find(:all, :conditions = [parents.name LIKE 'Clin%' Or how??? And what if I want to add

[Rails] String split help

2009-01-23 Thread James Bond
I have string: xxx | yyy | zzz | ddd I need to split it to: xxx, yyy, zzz and ddd, make link to every word like: a href=xx/a So result must by: from this: xxx | yyy | zzz | ddd to this: a href=xx/a, a href=yy/a, a href=zz/a, a href=dd/a How can I do it? -- Posted via

[Rails] session[:aa][:bb]

2009-01-19 Thread James Bond
Why this doesn't work? session[:aa][:bb] = xxx -- 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

[Rails] Re: session[:aa][:bb]

2009-01-19 Thread James Bond
Frederick Cheung wrote: On 19 Jan 2009, at 18:05, James Bond wrote: Why this doesn't work? session[:aa][:bb] = xxx probably because session[:aa] is nil Fred How to fix it? index 25009 out of string -- Posted via http://www.ruby-forum.com

[Rails] will_paginate help

2009-01-19 Thread James Bond
Can I limit results in will_paginate plugin? I want to paginate only 100 results 10 per page. -- 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

[Rails] Re: session[:aa][:bb]

2009-01-19 Thread James Bond
I can't make this work: @tmp = xxx sessi...@tmp][:yyy] = zzz -- 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

[Rails] Number of entries

2009-01-13 Thread James Bond
I use will_paginate to get results: @results = Users.paginate(:all, :conditions = ... But how can I get a number of reults? -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups

[Rails] Re: Number of entries

2009-01-13 Thread James Bond
How can I write it simple? if @results.empty? x = 0 else x = 1 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

[Rails] Re: params[:xxx]

2009-01-11 Thread James Bond
Vishwanath Nayak wrote: @city = params[:user][:city] if params[:user] params[:user][:city]Should do the trick Yes it do, but it not simple any more, as it was before. For example: This works in old rails versions, but not in (2.2.2), why? @word = params[:search][:word] || params[:word] ||

[Rails] Re: params[:xxx]

2009-01-10 Thread James Bond
@city = params[:user][:city] Why I get: You have a nil object when you didn't expect it! You might have expected an instance of ActiveRecord::Base. The error occurred while evaluating nil.[] Even if I try: @city = params[:user][:city] if params[:user][:city] I get same error. -- Posted via

[Rails] Re: params[:xxx]

2009-01-10 Thread James Bond
cloper wrote: Try || not | Same error :( -- 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