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,
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/.
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
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
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
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
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,
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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] ||
@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
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
24 matches
Mail list logo