Forum: Ruby on Rails Problem with Yaml

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Bolo (Guest)
on 2007-03-19 13:10
(Received via mailing list)
Hello

I try to read yaml file. my model

class Enseignant < ActiveRecord::Base
  file_column :photo,
      :magick => {:geometry => "250x250>"},
      :root_path => File.join(RAILS_ROOT, "public/", "upload"),
      :web_root => "upload/"

  validates_file_format_of :photo, :in => ["gif", "png", "jpg"]
  validates_filesize_of :photo, :in => 15.kilobytes..1.megabyte
  #validates_image_size :photo, :min => "1200x1800"

  has_many :contributions
  has_many :enseignements, :through => :contributions
  has_one :user


  def adress
     #chargement du fichier de configuration
      adresse = YAML::load(IO.read("#{RAILS_ROOT}/db/adresses.yml"))
      return "totto"
  end
end

In my controler

  def show
    @enseignant = Enseignant.find(params[:id])
    @adresse = @enseignant.adress
     #########################################
     # Les Contributions de Cette enseigant
     @prof_enseigns = @enseignant.enseignements
     @contribution = Contribution.new
     @enseignements = Enseignement.find(:all, :order => "libelle")
     @enseignants = Enseignant.find(:all, :order => "nom")
     #########################################
    respond_to do |format|
      format.html  show.rhtml
      format.xml  { render :xml => @enseignant.to_xml }
    end
  end

On my browser i have this error

SystemStackError in EnseignantsController#show
stack level too deep

And with the console that

>> prof = Enseignant.find(1)
=> #<Enseignant:0x36cd9ec @attributes={"....i"}>
        from (irb):10
>> prof.adress
>> false


Can you help me

Thanks
Bolo (Guest)
on 2007-03-19 17:32
(Received via mailing list)
It's correct ?

YAML::load(IO.read("#{RAILS_ROOT}/db/adresses.yml"))
This topic is locked and can not be replied to.