Thursday, June 9, 2011

[Rails] Take a value from tables

Hi, I am new in Rails, and now i have a problem to take data from more
4 tables in DB

This is my code:

//user model
belongs_to season
belongs_to album
has_many albums

#### ----->
def get_pic

@pic = Picture.where(:album_id => 'Album.album_id' ,
user.where(:culture_id => 'Culture.culture_id')).first

end
### ----->

// Picture model//
belongs_to season
belongs_to album

//Culture model//
has_many pictures
has_one


// album model//
has_many pictures
has_many pictures through => 2011year
has_many pictures through => 2010year
has_many pictures through => 2009year

//2011yea model //
belongs_to picture

//2010yea model //
belongs_to picture

//2009yea model //
belongs_to picture

and i want to to take the image data from PICTURE table

picture_id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
album_id integer NOT NULL,
culture_id integer NOT NULL,
image binary

my user controller is

def show
@user= User.all
@my= User.get_pic

end

Please help.. i want stuck almost a week,. how i can i take a value
in Picture table.
Plus, i have caused a problem on this code as well

@pic = Picture.where(:album_id => 'Album.album_id' ,
user.where(:culture_id => 'Culture.culture_id')).first

it causes a syntax error


Please help . please help ... thanks thanks
Thanks

--
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-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate