Controller not recognizing installed Gem - ruby-on-rails

Okay, I know this is a bit of a simple question, but I can't seem to get it to work. I have installed the SmarterCSV gem in my Rails 4 app and am trying to use it in my controller like so:
SmarterCSV.process("/files/csv_file.csv")
I can do this exact process in the rails console for this app, but I cannot seem to get it to work in my controller. Every time I just get the Rails Dead Screen saying uninitialized constant MyController::SmarterCSV. I have tried adding the line
require 'smarter_csv'
But that also breaks to the Rails Dead Screen with the error cannot load such file -- smarter_csv
Any help would be greatly appreciated, Im not entirely sure what I can do...

you can try require 'smarter_csv/smarter_csv' as this is the path of the file in the gem https://github.com/tilo/smarter_csv/blob/master/lib/smarter_csv/smarter_csv.rb

Don't forget to restart your application after bundle install

Related

Issue adding Bootstrap on Ruby on Rails Project

This is what I followed in order to get started with bootstrap on Ruby on Rails.
I followed every step exactly the same. However, I keep running into the same error for some reason. When I do not do any thing (i.e. do not use bootstrap) everything works (but the application looks trashy).
Whenever I use bootstrap, I get:
invalid regexp character
This is the application trace:
(execjs):24299
app/views/layouts/application.html.erb:8:in `_app_views_layouts_application_html_erb__337612969_59863020'
I have no clue what is happening.
P.S. I am a beginner. So if the solution is simple then, yeah...
remove #gem 'duktape' from gem file..the issue will be solved

pdf.js gem producing errors

I am a rails novice and trying to create my web portfolio in Cloud9. I wanted to display my resume.pdf in the user browser so I installed this gem gem 'pdfjs_rails' now my app doesn't even start in cloud 9. It show the following error messages in the terminal:
Please help me. How can i revert it back? thanks
Doesn't look like anything related to pdfjs (no point in that direction). Are you sure you've selected the right runner in Cloud9? See:
https://community.c9.io/t/error-when-running-ruby-project/11799/4
More in general: if you think an issue would be related to a gem, you can simply remove it from the Gemfile and run gem bundle to 'revert' to a previous state.

Ruby on Rails Vacuum Gem

I am new to Ruby on Rails and I am trying to access the Amazon Product API using the Vacuum Gem. Based off this code https://gist.github.com/frankie-loves-jesus/89d24dd88579c7f912f3 I am getting an error at the first line
request = Vacuum.new('GB')
telling me that I have an "Uninitialized constant AmazonAPIController::Vacuum" every example on this gem tells me to use this line of code but I can't understand how to fix the error. It seems to be as simple as putting the code into my controller and showing it.
You didn't add the gem to your Gemfile I guess and didn't run bundle install afterwards. Also you should make sure to restart your Rails server after every change in your Gemfile.
If all that doesn't help, you also could try to just gem install vacuum and then require 'vacuum' in the file you are using (but I would recommend getting it to work on another way).

How to actually use rails-settings?

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'm Getting An Uninitialized Constant Error From A Recently Installed Gem. How do you fix this?

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

Resources