uninitialized constant Users ruby on rails - ruby-on-rails

I have an app that I am working on, and there appear to be two key problems: due to a problem undetectable by me, the webapp I am working on returns the error "uninitialized constant Users" and the error "uninitiallized constant SubmitController." The code for the webapp is here. I have tried renaming multiple, possibly violating variables, and attempted to rid the app of the errors. However, I have not been sucessful. The code where the errors most likely originate are from app/views/users/show.html.erb, app/views/users/show.html.erb, app/controllers/user/submit.html.erb, app.controllers/user/submit_controller.rb, app/models/Submit.rb, app/models/user.rb, app/controllers/users_controller.rb, config/routes.rb.
Thanks in advance.

You have error because you don't have SubmitsContoller. Also you need to move app/controller/users/submit.erb to views folder. And one more rename file Submit.rb to submit.rb.
And to make it works create submit_controller.rb in controller folder.

Related

NameError wrong constant name primary — yet `primary` doesn't exist?

I am getting an error that randomly pops up whenever I make changes. If I refresh the page after getting the error, it goes away. The error:
NameError wrong constant name primary
I have searched my entire application and I do not have any methods or constants using the word primary. Why is my Rails application trying to call something that doesn't exist?
Okay, so it looks like this will be fixed in the next release. The fix was referenced here:
https://github.com/rails/rails/issues/36757
So, wait a week or two, update Rails and this will be resolved.
Edit: As a workaround, I reverted from 6.0.0.rc2 to 6.0.0.rc1

Which does RailsAdmin initialize models from ("Uninitialized Constant" Error)?

I am trying to use RailsAdmin and am getting an Uninitialized Constant TableNameX error. I did indeed misspell TableNameX originally.
I figured that if I went and changed all the mis-spelled spots the problem would resolve itself. It hasn't, so I seem to be missing a spot--but my searches within Eclipse are not turning anything up!
Which folder/folder would RailsAdmin be reading from?
What does your trace look like?
Also have you looked into /config/initializers/rails_admin.rb to see if your TableNameX is there and you simply forgot to change it? :)
P.S: And don't forget to restart the server, initializers only run once at the server bootup.

Rails: Reloading code in development environment gives a "ApplicationHelper has been removed from the module tree but is still active!" error

I upgraded to Rails 4 and now when some changes are made to the code, or when I do a reload! in rails console, I will get an ArgumentError: A copy of ApplicationHelper has been removed from the module tree but is still active! error.
I'm not the only one with this problem but still cant find existing solutions that work yet.
I've never encountered that problem before. I'm using Rails4 as well.
I think you have to call your controller(which is shown in the ArgumentError) explicitly in your dependent controllers.
Can you try adding this line on top inside the class?
require "_controller"
Then try rails server -e production
See if this helps. Sorry I wish I could give you more detailed solution.
If all else fails, rollback might be an option to consider.

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!

Activerecord error .include? nil

I am writing a rails app, which has some modules and methods loaded via the lib directory, we have also added some methods in restful authentication module, now everytime when i run using mongrel server on production i dont get this error, although because model classes and controller classes are cached, but in development i do get this error, after the first time, so i start my server on development and run once i get the correct behavior, but when i refresh the page i get this nil.include error, while it displays that the each method is getting a nil to iterate, also i have done some homework, as i added the puts method, for all methods for that instance while iterating, i dont get any method definations for attributes of the table, like ID, name, title. i am unsure about this,
I am using Rails 2.2.2 and ruby 1.8.7.
Server is mongrel & webrick.
This situation happened to me, where I used to get the error only after the refresh (i.e., second call to the server).
It may be that you have defined a module in your /lib directory which does not matches the rails convention of file-naming. And you are using the require "filename.rb" statement to get the module.
Try using require_dependency "filename.rb" instead.
Let me know if problem still exists, we may look deeper.
You should look into the log/development.log or log/production.log files (depending on the environment you are investigating). The first line of the stacktrace shows the source of the error. Try to find the error there or post the relevant line (this and some above).

Resources