Im trying to set up api endpoints for my rails application and keep receiving this error my environment is Ruby 2.6 and Rails 5.2 and im using the 'grape' gem for the api here is the blog I followed to set it up. https://medium.com/#ryanwaldorf/how-to-add-an-api-to-an-existing-rails-app-1d2419ba91bd
here is a link to my repo https://github.com/jslack2537/apiDemoApp
I believe the issue is wither in my config/routes.rb or my application.rb files.
But I could be totally wrong. This is a challenge app and not going to be used in production.
This mainly occurs when naming conventions doesn't match. Try changing api/v1/user.rb to api/v1/users.rb which also the blog suggests. You missed a 's'.
Related
I am developing a simple gem. as part of it, I want data-caching to which I need rails gem. I included the required statements in gemspec. But still, it is not loading Rails. I am getting below error
NameError:
uninitialized constant FormattingHelper::Rails
Instead of using Rails for caching, I used below class and fixed the problem
ActiveSupport::Cache
Like many Rails applications, we have a few classes we define in the lib/ folder. We make sure to let Rails know about them in the config/application.rb file like so
config.autoload_paths += Dir[Rails.root.join('lib'), Rails.root.join('lib', '**')]
And that has worked perfectly up until now with no problems. However recently we have been getting random occurrences of "Uninitialied Constant" errors in staging/production. Most of the times things work fine, it's just every once in a while that things break down. Opening a Rails console and the classes are always there.
I tried to better understand how Rails does the autoloading magic, so I read this great article: http://urbanautomaton.com/blog/2013/08/27/rails-autoloading-hell/, but nothing in it helped me.
I also tried a few things that I thought might work, like requiring all the files individually in an initializer, but nothing worked.
I'm using Ruby 2.1.1, Rails 3.2.19, Phusion Passenger 4.x. Anything else that might help? How might Constants become undefined or inaccessible from somewhere? Maybe a gem is messing with the way Rails modifies constant lookup...
Update: I have not enabled threadsafe mode
I'm trying to use rails-settings gem but i'm not sure how to do that.
I've added ledermann-rails-gem gem to Gemfile, runned bundle install, generated a migration based on what's written in wiki, runned rake db:migrate, restarted a server and now, when i'm trying to do anything from rails-settings wiki, i'm getting an error.
Let's say i want to create new variable so i'm putting this code to my controller:
Settings.foo = "bar"
It gives me the following error:
uninitialized constant ApplicationController::Settings
I'm quite 'fresh' in rails development and probably there is some small thing which wasn't mentioned in the wiki because it's obvious (but not for me!). Any help would be appreciated
I recently installed the Citier Gem. Its Gem a solution for simple Multiple Class Inheritance in Rails. After setting up models per the instructions and running Rake, I am getting the following error:
uninitialized constant Books::Writable
*/citier/core.ext.rb:33:in 'create_citier_view'
Its been my experience that this error message usually means the Gem is not installed properly, but I've checked my Gemfile and did a Bundler Show command and everything seems to be in order. Apparently, the core.ext file referenced in the error is supposed to be extending ActiveRecord to create views that are utilized for Multiple Class Inheritance.
I checked all the usual places for the problem but can't seem to figure this out. In suggestions or ideas would be greatly appreciated. I've been stuck on this one for a couple of days now.
Thanks for you input.
Simply type require 'rails_sql_views' in config/application.rb
U may need install gem rails_sql_views
I am trying to implement a tagging system for my rails app. I employed the popular plugin acts_as_taggable_on_steroids, and followed the instruction on how to install it. I then included acts_as_taggable in the model that I would like to have tags on, but then when I try to start the server I keep getting the error method_missing': undefined local variable or methodacts_as_taggable' for # (NameError)
I look on google and the author suggested to try acts_as_taggable_on, but still this did not fix the problem. I am struggling on this problem for hours already, but still don't know where is the problem. Could anyone please shed some light?
Thank you very much for all the help!!
Did you try to require the lib ruby of act as taggable on steroids at the beginning of your file?
Something like:
require 'acts_as_taggable'
maybe?