Rails App Suddenly Not Working - ruby-on-rails

I was just working on one of my models when my Rails app would not work anymore. Even typing out commands like rails -v, rails, c, bundle install, or any command is giving out the same error. What's causing it is a syntax error on the file fileutils.rb. I'm using the ruby version ruby-1.9.3-p551.
First set of error messages.
(I have not included the middle part of the error messages.)
Last set of error messages.
I do not understand as to what caused the file fileutils.rb to be modified or be syntax errored.

I have modified the fileutils.rb by copy-pasting lines 309-421 from another fileutils.rb file.
I got it working again but I am still confused as to what corrupted my file.

Related

Error Installing importmap on rails application

I am having troubling setting up an existing rails application. I am supposed to set up importmap but it is giving me trouble.
If having trouble viewing the uploaded pic, it says "rails aborted!
Don't know how to build task 'importmap:install'"
Rails error pic
If I run "rails --tasks" importmap:install does show up.
rails --tasks output snippet
As per the attached screenshot of the task list, the actual task name apparently is called app:importmap:install instead of importmap:install.
I'm not sure why that might be the case, though. It seems to me like you might (accidentally?) be working on a Rails engine instead of an actual app?

rails db:migrate giving warning and not creating any table

When I start doing code on (see image below) rails I saw rails guide to getting start with it. There's a command rails db:migrate for creating table and stuff. But its giving only warning and not creating any table.
The code has executed successfully and there are no issues with it. The warnings are because either your code, or some of the gems you have used in the code contain some methods that are deprecated.
If the warning comes from your code, try to fix them. If it is from any dependency, then watch for updates, keep the gems updated, or you can also write to the gem developer to fix these warnings.

Psych Error: `parse': (<unknown>): could not find expected

`':' while scanning a simple key at line 16 column 1(Psych::SyntaxError)
I'm working on a Rails application tutorial and have had the above error come up several times. When I was getting this error it seemed to only be a problem if I used one particular terminal window. I have since restarted the computer and now it is a problem regardless of what I do.
I went to the project on github and copied the information in 'secrets.yml' into my file in case that was the issue but doesn't help. In fact I'm not sure if that is even the file causing the problem because when I shift the code in that file and save it I still get the same error; at those times it points to a line that is now blank in the 'secrets.yml'
Update.
now I am getting this when i run this command
rails generate simple_form:install --foundation
-bash: $: command not found.
only change I did was start the code in 'secrets.yml' lower down, and i added a secret key to my .bash_profile, as it was suggested in tutorial and I had not done it before, and thought that might be the problem.
Update 2
shut down terminal and tied again and getting the original problem "psyche Error" Yes, thank you for your feedback, I too, although not sure why, suspect it is to do with the 'secret' file or could it be changes the tutorial told me to make to my .bash_profile. The instructions were not very clear, wondering if that is where I messed up. If that is so then I would not know how to fix that.
The Psych gem is the wrapper around libyaml and used within Ruby's YAML class, so it's not surprising you think it could be the 'secrets.yml'; a YAML config file. I'd stay the course and find what isn't being formatted correctly.

Rspec having issues with file path

I am basically having the exact same issue as this user on this question:
Rspec cannot load error
Specifically, when I look at the error log, I see that for some reason it is adding an extra "/spec" to the file path in loading the static_pages_spec.rb file
/Users/anantvinjamoori/.rvm/gems/ruby-2.1.1#railstutorial_rails_4_0/gems/rspec-core-
2.13.1/lib/rspec/core/configuration.rb:819:in `load': cannot load such file --
/Users/anantvinjamoori/helpondemand/sample_app2/spec/spec/requests/static_pages_spec.rb
(LoadError)
This directory does not exist on my computer, so it is no surprise that this error is being generated. However, I am not sure how to stop it from doing this. The previous user just said he "would check his commits" and never followed up. How can I stop RSpec from doing this incorrect path assignment?
Because it seems others have had this problem, thought I would contribute my mistake (even though it may seem stupid)
I was executing rspec from the wrong directory from the terminal (ie i was executing it from the spec directory itself, which was probably the reason the extra /spec was being added.
Bottom line: restarting your terminal never hurts!

Passenger "No such file to load" error for Model

I'm having a problem with deploying a Rails 3 app to a Passenger/Apache2/RVM server running Ubuntu 11.10.
I'm getting the error:
A source file that the application requires, is missing.
...
Error message: No such file to load -- Goal
Exception class: LoadError
Goal is one of my Rails Models.
I've seen a lot of people with a similar error message, but their issues seem to relate to missing bundles/gems - not model files! Their problems were resolved by ensuring permissions were set up correctly, so to that end I've got:
Apache running as www-data, as is Passenger. RVM is installed as www-data and I've chown'd the entire web app directory to www-data.
I've been wrestling with this for some time now and am really out of ideas - if anyone has any suggestions I'd be very grateful!
You might probably have the file structure of your Rails app wrong. Are you sure you have the "goal.rb" file within {your_app_root_url}/app/models/ ?
To me, if I am seeing the error when you view the app in browser, it seems like your rails app and passenger(with apache2) are working fine. The other possibility is you might be looking at wrong app folder which passenger is set up to.
It's hard to tell what's wrong. Please provide more details of how you set up your passenger with your rails app directory. Also it would help if you could show what's inside your app (app structure) and what's inside goal.rb model file.
Well I've solved it. Turned out that a work around for a problem with yaml encoded model archives (i.e. an explicit require of Goal) in a completely unrelated Model was causing the error to appear. Looks like it only rears its head in production - probably due to the differences between the class loaders used in development vs. production.
Tough one to find... the stack trace didn't include a reference to where the problem actually was!

Resources