11175
(-- --)
October 6, 2009, 4:19pm
1
Alexei Spirit wrote:
Alexei Spirit wrote:
Something like this:
Manufacturer.all :joins => :description, :conditions => {:descriptions
=> {:locale => I18n.locale}}
Version with :order
Manufacturer.all :joins => :description, :order => :name, :conditions =>
{:descriptions => {:locale => I18n.locale}}
Thank you so much.
I did this based upon what you wrote above and it works great.
find(:all, :joins => :descriptions, :order => :name, :conditions =>
{:descriptions => {:locale => I18n.locale}})
Thanks again.
11175
(-- --)
October 6, 2009, 4:37pm
2
Mitchell Gould wrote:
Alexei Spirit wrote:
Alexei Spirit wrote:
Something like this:
Manufacturer.all :joins => :description, :conditions => {:descriptions
=> {:locale => I18n.locale}}
Version with :order
Manufacturer.all :joins => :description, :order => :name, :conditions =>
{:descriptions => {:locale => I18n.locale}}
Thank you so much.
I did this based upon what you wrote above and it works great.
find(:all, :joins => :descriptions, :order => :name, :conditions =>
{:descriptions => {:locale => I18n.locale}})
Thanks again.
One last question.
I need the description for the manufacturer that is found in the table
descriptions. How do I get this columns info and how do I access it in
the view?
Thank you in advance
11175
(-- --)
October 6, 2009, 5:04pm
3
One last question.
I need the description for the manufacturer that is found in the table
descriptions. How do I get this columns info and how do I access it in
the view?
Thank you in advance
With this one:
find(:all, :joins => :descriptions, :order => :name, :conditions =>
{:descriptions => {:locale => I18n.locale}})
since you descript your associations you can get manufacturers with all
associated models, then you can use it anywhere
Like this one for example:
@manufacturers = Manufacturer.all :joins => :description, :order =>
:name, :conditions => {:descriptions => {:locale => I18n.locale}}
@manufacturers.each do |manufacturer|
puts manufacturer.description.description
end
11175
(-- --)
October 6, 2009, 5:06pm
4
I suppose this would very helpfull for u:
Active Record Query InterfaceThis guide covers different ways to retrieve data from the database using Active Record.After reading this guide, you will know: How to find records using a variety of methods and conditions. How to specify the order,...
11175
(-- --)
October 7, 2009, 12:41am
5
Alexei Spirit wrote:
I suppose this would be very helpfull for u:
Active Record Query Interface — Ruby on Rails Guides
Yes Alexei that is the perfect guide. Thanks again.