views:

19

answers:

1

NoMethodError in ContainerformatsController#create undefined method `yuvstreams' for #

hi all, i am getting this error i don't no what happened ,its working fine few days before but it not working this is code for create function

@containerformat = Containerformat.new(params[:containerformat])

if @containerformat.containerFmt == 'TS'
  @containerformat = Containerformat.new(params[:containerformat])
  @transportstream =
    @containerformat.transportstreams.build(params[:transportstream])
  @transportstream.save
  @program = @transportstream.programs.build(params[:program])
  @program.save
  @user = @containerformat.users.build(params[:user])
  @user.save

  if params[:videoCodec_id]!= nil
    @stream = @program.streams.build(params[:stream])
    @stream.videocodec = Videocodec.find(@stream.videoCodec_id)
    @stream.save
  end
  if params[:audioCodec_id]!= nil
    @stream = @program.streams.build(params[:stream])
    @stream.audiocodec = Audiocodec.find(@stream.audioCodec_id)
    @stream.save
  end

end

if @containerformat.containerFmt == 'PS'
  @programstream =
    @containerformat.programstreams.build(params[:programstream])
  @subtitle = @programstream.subtitles.build(params[:subtitle])
  @subtitle.save
  @programstream.save
  @stream = @programstream.streams.build(params[:stream])
  @user = @containerformat.users.build(params[:user])
  @user.save

  if params[:videoCodec_id]!= nil
    @stream = @programstream.streams.build(params[:stream])
    @stream.videocodec = Videocodec.find(@stream.videoCodec_id)
    @stream.save
  end
  if params[:audioCodec_id]!= nil
    @stream = @programstream.streams.build(params[:stream])
    @stream.audiocodec = Audiocodec.find(@stream.audioCodec_id)
    @stream.save
  end

end

if @containerformat.containerFmt == 'YUV'
  @yuvstream = @containerformat.yuvstreams.build(params[:avistream])
  #@subtitle = @yuvstream.subtitles.build(params[:subtitle])
  #@subtitle.save
  @yuvstream.save
  @stream = @yuvstream.streams.build(params[:stream])
  @user = @containerformat.users.build(params[:user])
  @user.save

  if params[:videoCodec_id]!= nil
    #@stream = @programstream.streams.build(params[:stream])
    #@stream.videocodec = Videocodec.find(@stream.videoCodec_id)
    #@stream.save
  end
  if params[:audioCodec_id]!= nil
    #@stream = @programstream.streams.build(params[:stream])
    #@stream.audiocodec = Audiocodec.find(@stream.audioCodec_id)
    #@stream.save
  end

end


if @containerformat.containerFmt == 'AVI'
  @avistream = @containerformat.avistreams.build(params[:avistream])
  @avistream.save
  @stream = @avistream.streams.build(params[:stream])
  @user = @containerformat.users.build(params[:user])
  @user.save

  if params[:videoCodec_id]!= nil
    @stream = @avistream.streams.build(params[:stream])
    @stream.videocodec = Videocodec.find(@stream.videoCodec_id)
    @stream.save
  end
  if params[:audioCodec_id]!= nil
    @stream = @avistream.streams.build(params[:stream])
    @stream.audiocodec = Audiocodec.find(@stream.audioCodec_id)
    @stream.save
  end
end

i have yuvstreams as table in my databae like other tables avisteams,programstreams table plzz help me out

A: 

You need a has_many :yuvstreams in your Containerformat class.

This defines the relationship between containerformats and yuvstreams from the containerformat point of view. You can find more details in the api docs for the has_many method. Basically though, without that you can't refer to yuvstreams from a containerformat.

One additional point on style. Typically rails uses an _ and camel case to make names more readable. So you would have YuvStream and ContainerFormat as your class name and has_many :yuv_streams as your association definition. Rails expects this kind of naming and can sometimes make educated guesses about things if you use it.

Shadwell
yaa Shadwell thanks for your kind information
AMIT
could you refer me some good documents to start in rails
AMIT
http://guides.rubyonrails.org/getting_started.html is the best I think. Feel free to accept the question if it answers what you were after ;)
Shadwell