473,407 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

taking value from DB in rails

47
Hi, I am new in Rails, and now i have a problem to take data from one of tables in DB

This is my code:

Expand|Select|Wrap|Line Numbers
  1. //user model
  2. belongs_to season
  3. belongs_to album
  4. has_many albums
  5.  
  6. #### ----->
  7. def get_pic
  8.  
  9. @pic = Picture.where(:album_id => 'Album.album_id' ,
  10.       user.where(:culture_id => 'Culture.culture_id')).first
  11.  
  12. end
  13. ### ----->
  14.  
  15. // Picture model//
  16. belongs_to season
  17. belongs_to album
  18.  
  19. //Culture model//
  20. has_many pictures
  21. has_one
  22.  
  23. // album model//
  24. has_many pictures
  25. has_many pictures through => 2011year
  26. has_many pictures through => 2010year
  27. has_many pictures through => 2009year
  28.  
  29. //2011yea model //
  30. belongs_to picture
  31.  
  32. //2010yea model //
  33. belongs_to picture
  34.  
  35. //2009yea model //
  36. belongs_to picture
  37.  
  38.  
and i want to to take the image data from PICTURE table

Expand|Select|Wrap|Line Numbers
  1. picture_id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  2. album_id integer NOT NULL,
  3. culture_id integer NOT NULL,
  4. image binary
  5.  
  6. my user controller is
  7.  
  8.   def show
  9.        @user= User.all
  10.        @my= User.get_pic
  11.  
  12.   end
  13.  
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
Jun 10 '11 #1
0 1528

Sign in to post your reply or Sign up for a free account.

Similar topics

23
by: flab ba | last post by:
The pragmatic programmers (Dave & Andy) are spreading a good word about RubyOnRails. I was wondering if there are any Python programmers who are /also/ familiar with Rails - and if they could...
28
by: flamesrock | last post by:
Firstly, this topic is NOT intended for trolling or starting any flame wars. I want to know if anyone has experience with these frameworks, and if so, how do they compare? Which one do you...
122
by: seberino | last post by:
I'm interested in knowing which Python web framework is most like Ruby on Rails. I've heard of Subway and Django. Are there other Rails clones in Python land I don't know about? Which one...
9
Niheel
by: Niheel | last post by:
I've used the following tutorials to help be get a better understanding of Ruby On Rails or ROR. Installing Ruby on Rails - Fedora / Lighthttpd Tutorial & Setup for Ruby on Rails Rolling with...
92
by: Ray | last post by:
I just moved to another company that's mainly a Java/.NET shop. I was happy to find out that there's a movement from the grassroot to try to convince the boss to use a dynamic language for our...
42
by: kenneth.m.mcdonald | last post by:
First, I don't intend this to be a flame war, please. Python and Ruby are the only two languages I'd willingly work in (at least amongst common languages), and TurboGears and Rails seem roughly...
10
by: lawrence k | last post by:
I work mostly in PHP, but at the web design firm where I work we are thinking of switching to Ruby on Rails. Our lead designer recently installed Typo on a client's site and he said to us, with...
3
by: Mitchell Gould | last post by:
I just update my RubyGems and Rails. I am working on Rails 2.3.2 and everything was working prior to this update. Now I am getting the following error: undefined method `inject' for...
0
by: Brad Chin | last post by:
Hi, I'm still new to Ruby on Rails, and I want to utilize ActiveRecord::Observer. I got Observer working under the rails environment by putting my rb files under app/model and configuring...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.