taking value from DB in rails

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Wiinie
    New Member
    • Feb 2011
    • 47

    taking value from DB in rails

    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:

    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

    Code:
    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(:cul ture_id => 'Culture.cultur e_id')).first

    it causes a syntax error

    Please help . please help ... thanks thanks
    Thanks
Working...