Hey guys,

I'm trying to access a YAML file to set up some options in a select
drop-down that was previously hard-coded.

I have the following in my controller:

require "yaml"
require "pp"
require "util"
require "date"

# set the path
$LOAD_PATH << File.join(File.dirname(__FILE__), '../')

require 'rate'
require 'test/unit'
require 'yaml'

#require 'rubygems'
#require 'ruby-debug/debugger'

YAML_CONFIG_FILE_STR = "LawyersProfessionalLiability.yaml"
YAML_CONFIG_FILE =
File.join(File.expand_path(File.dirname(__FILE__)),"..",YAML_CONFIG_FILE_STR)

class LplShortFormAppsController < ApplicationController

  def initialize(filename = "LawyersProfessionalLiability.yaml")
    # load all lookup tables
    @RateLookup = YAML::load(File.open(filename))

    reset
  end

  def new
    # load all lookup tables
    @RateLookup = YAML::load(File.open(YAML_CONFIG_FILE))
    @deductibles = @RateLookup["Deductible"]
    @desired_limits = @RateLookup["Liability Limits"]

    @lpl_short_form_app = LPLShortFormApp.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @lpl_short_form_app }
    end
  end
  ...
end

And the code in the view doesn't matter yet because I keep receiving:

 Errno::ENOENT in Lpl short form appsController#index

No such file or directory - LawyersProfessionalLiability.yaml

RAILS_ROOT: /Users/brwn/work/demo
Application Trace | Framework Trace | Full Trace

/Users/brwn/work/demo/app/controllers/lpl_short_form_apps_controller.rb:31:in
`initialize'
/Users/brwn/work/demo/app/controllers/lpl_short_form_apps_controller.rb:31:in
`open'


I don't know why. Where is the YAML file supposed to go? I've tried
placing it in /app, /public, /views/, /views/lpl_short_form_apps (the
view where the YAML file is being called to load).

Can anyone assist?

Thanks,
  Ahad
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to