Problem with Yaml


#1

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


#2

It’s correct ?

YAML::load(IO.read("#{RAILS_ROOT}/db/adresses.yml"))