thesecretmaster thesecretmaster - 3 months ago 7
Ruby Question

Sinatra cannot find file that is clearly there

I do not know what to do. It is giving me this error on the line which contains

erb :RUSure
I don't understand why that is different from any other lines where I use
erb :whateverFileName
It is not that it is in a different directory, because it is in the same directory.

My error:

2015-05-30T21:50:59.901059+00:00 app[web.1]: 2015-05-30 21:50:59 - Errno::ENOENT - No such file or directory @ rb_sysopen - /app/views/RUSure.erb:


In case this is helpful, my tree:

.
├── Gemfile
├── Gemfile.lock
├── Procfile
├── Rakefile
├── app.rb
├── db
│   ├── migrate
│   │   └── 20150527124739_establish_all.rb
│   └── schema.rb
├── models.rb
└── views
├── RUSure.erb
├── changePassword.erb
├── createQuiz.erb
├── deleteStu.erb
├── displayAns.erb
├── editDB.erb
├── error.erb
├── getQN.erb
├── home.erb
├── layout.erb
├── noneFound.erb
├── select.erb
├── setPass.erb
├── sucess.erb
└── test.erb


Here is the section that is throwing the error:

post '/adminRUSureDelete' do
admin_check
@name = params[:name]
@year = params[:year]
@band = params[:band]
if @name == "" and @year == "" and @band == "" then
var = nil
elsif @name == "" and @year == "" then
var = Student.where(band:@band)
elsif @year == "" and @band == "" then
var = Student.where(name:@name)
elsif @name == "" and @band == "" then
var = Student.where(year:@year)
elsif @name == "" then
var = Student.where(year:@year,band:@band)
elsif @year == "" then
var = Student.where(band:@band,name:@name)
elsif @band == "" then
var = Student.where(year:@year,name:@name)
else
var = Student.where(year:@year,name:@name,band:@band)
end
if var == nil then
erb :noneFound
else
var.each do |i|
@list = "#{@list}<p>#{i.name}</p>"
end
var.each do |i|
@send = "#{@send},#{i.id}"
end
erb :RUSure # THIS IS THE LINE WHERE IT GIVES ME THE ERROR.
# It works if any of the other if statements are triggered, but just not here.
end
end


I am willing to add any information that would be helpful.

Answer

The file is using upper case characters. Make sure the filename and the name in your code match in case. If the filename is really e.g. RUsure.erb then your code won’t work.