NoMethodError (undefined method `new' for LinkedIn:Module) - ruby-on-rails

I'm just currently trying to follow tutorials to learn ruby and rails etc. So I apologise in advance for the newbie'ness of this question.
I've had a bunch of code dropped on me with instructions to 'get that up and see what it does'.
Its a rails app that was up at one time and now needs to be resurrected.
And I've been hammering at it for a week now.
So, I got the rails app extracted into a folder.. and used rvm to set myself up with
ruby 1.9.3p448 (2013-06-27 revision 41675) [i686-linux]
Rails 3.0.7
On ubuntu 12.04
Cos I was told the app had been a 'rails 3' app.
I had to do a good bit of changing things in the Gemfile as gems were no longer available etc. Spent ages wrestling with Rake errors until I finally forced it back to 0.8.7 and got a db:migrate to work.
And now I can get 'rails server' to startup WEBrick.
However when I point a browser at http://localhost:3000/ I get the output below.
They thing I'm at a loss with is the "NoMethodError (undefined method `new' for LinkedIn:Module)" as I've grepped and I don't actually have a LinkeIn module in the code.
I just have a Gemfile entry for the
gem "linkedin", "~> 0.4.1"
And I just can't find out where in the code this error is getting thrown from.
If someone could help me identify what file/line that the error is emanating from .. or tell me that its actually coming from the LinkedIn gem than it would be a great help.
Its justkilling me that I can't find out where the code is so that I can go fix it.
The Application Trace on the webpage is blank.
To me it looks like its happening before the code gets to the controller specified for the root route in the routes.rb.
So, please, any help at all.. how to turn on tracing, where to go to find out whats going on at all..
Thanks
Vida
*Console output on browse to root*
/home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/rake-0.8.7/lib/rake/alt_system.rb:32: Use RbConfig instead of obsolete and deprecated Config.
=> Booting WEBrick
=> Rails 3.0.7 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2013-07-30 07:29:01] INFO WEBrick 1.3.1
[2013-07-30 07:29:01] INFO ruby 1.9.3 (2013-06-27) [i686-linux]
[2013-07-30 07:29:01] INFO WEBrick::HTTPServer#start: pid=13793 port=3000
Started GET "/" for 127.0.0.1 at 2013-07-30 07:29:53 -0600
NoMethodError (undefined method `new' for LinkedIn:Module):
Rendered /home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/actionpack-3.0.7/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.1ms)
Rendered /home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/actionpack-3.0.7/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (4.3ms)
Rendered /home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/actionpack-3.0.7/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (9.0ms)

Just in case anyone else happens across this...
Problem was solved with the help of an experienced Rails programmer.
What he did was start from fresh and use rvm to straighten out some issues with my installation.
So, it wasn't a problem in code, per say, but an issue around installing rails etc.
HTH someone.

Related

Ruby on Rails can't reach server

I'm trying to learn ruby on rails but can't manage to have the server working. I've been following 2 tutorials and, every time I come across the server section, for some reason I can't let it work.
First tutorial I tried was the one that can be found at http://installrails.com/
I follow every step and when I get to type $ rails server I get the error explained here Could not find gem 'turbolinks-source (~> 5)'
Since I could get it solved, I tried with the IFTTT tutorial with no better results since after following their instruction and adding the tzinfo-data gem that was apparently missing from their script, I get this log
[2019-06-08 19:12:03] INFO WEBrick 1.3.1
[2019-06-08 19:12:03] INFO ruby 2.3.3 (2016-11-21) [i386-mingw32]
[2019-06-08 19:12:03] INFO WEBrick::HTTPServer#start: pid=4504 port=3000
but still I can't reach the address they suggest (http://0.0.0.0:3000/).
It's pretty obvious to me that I'm missing something, but I really can't wrap my mind around it.
Should it help,
ruby version is 2.3.3p222 and rails one is 5.2.3
When running a Ruby on Rails application on a local machine the following two URL should work:
http://localhost:3000 or
http://127.0.0.1:3000
Btw: 0.0.0.0 basically means all IPv4 addresses on the local machine.
I friendly suggest you follow official rails guides here: https://guides.rubyonrails.org/getting_started.html
they are well written and designated to learn rails. You will find these guides helpful.

Rails won't exit on first CTRL-C

No Rails command will exit on the first CTRL-C. So rails s or rails c require me to hit control CTRL-C a second time and commands that previously wouldn't have required a CTRL-C at all such as rake routes / db:migrate now require me to press it.
The issue is not happening for any of my teammates. I'm on OSX using iTerm2. There are no instances of 'rescue Exception' in the app.
I've just reinstalled mysql using brew and the issue is still present. Rails version 4.0.5 and sql server version 5.6.27. Any idea where the issue might be?
[2016-01-13 16:18:33] INFO WEBrick 1.3.1
[2016-01-13 16:18:33] INFO ruby 2.1.2 (2014-05-08) [x86_64-darwin13.0]
[2016-01-13 16:18:33] INFO WEBrick::HTTPServer#start: pid=2329 port=3000
^C[2016-01-13 16:18:54] INFO going to shutdown ...
[2016-01-13 16:18:54] INFO WEBrick::HTTPServer#start done.
Exiting
^C
Honestly Webrick 1.3.1 was released in December 28, 2011 I would suggest moving away from this see webrick answer for the reasons.
As you have said that it happens in rails consoles and other tasks (You should really put this in the question as it helps with debugging) I would suggest it is a gem that is causing this (You should update your rails version anyway) but I would suggest using:
Ctrl-D
This should exit you straight away
I suspect this isn't as much an answer as a suggestion, but I started using Puma by default in my projects a while back, and given that Rails 5 is moving to Puma by default it may not be a bad suggestion.
I use a similar environment, OS X 10.11.2, iTerm 2, tmux, etc. I can't recall when or what prompted it, but at some point my WEBrick projects started behaving this same way, and I started moving them to Puma where possible which didn't seem to show the same behavior.
I know that doesn't really give a clear answer as to what's causing the issue, but also, I too know it's not system performance related.

GC.stat is undefined on Heroku's Cedar stack

This is currently demonstrated on my playground app, visiting it results in a 500, works now having deployed the fix given in the answer.
The error is was:
Processing by GcController#show as HTML
Completed 500 Internal Server Error in 0ms
NoMethodError (undefined method `stat' for GC:Module):
app/controllers/gc_controller.rb:4:in `show'
Conversely if you grab the Rails app from Github.
Then RAILS_ENV=production rails server and go to /.
You'll get:
{:count=>131, :heap_used=>193, :heap_length=>345, :heap_increment=>152, :heap_live_num=>127915, :heap_free_num=>29930, :heap_final_num=>0}
Is it safe to assume Heroku is using a patched GC?
Has anyone else encountered this? There doesn't appear to be any documentation about it.
I'm seeing some conflicting memory usage behaviour locally vs on Heroku, which is why I'm trying to GC.stat. I wonder if the differences could be accounted for by patched GC.
I also opened a Heroku issue for this.
Answer graciously stolen from JD at Heroku:
Cedar uses 1.9.2-p290 by default. I'm not sure if GC.stat is in 1.9.2
offhand, but it appears to not be on Heroku for sure. We don't patch
the Ruby versions we run.
I can confirm that if you specify ruby '1.9.3' in your Gemfile, GC.stat will work fine.

Ruby On Rails deployment - what version of RoR should I use? [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 11 years ago.
I am a Newbie on Ruby on Rails, and I've had some issues with the deployment of RoR applications.
EDIT 1: Trying to narrow down the question a bit. I am uncertain whether my issues with the deployment of my rudimentary Ruby apps are results of my erroneous setup and coding or conflicts in the version of Ruby on Rails I am currently using.
Rephrasing question: What version of Ruby on Rails should I use? Being a newbie to the frameworks, I just want my deployment process to be as smooth as possible. If 3.2 is the official download (as of jan 20, 2012) is it safe to use, and should I then use the latest stable version of Ruby (1.9.3-p0)? What about gems mentioned in books and writings? Should I always use the latest one?
Old discussion
I am following Ruby On Rails Tutorial. Following the instructions in the book I try to deploy on Heroku, but with no luck. Printouts from the Heroku log gives:
2012-01-22T18:26:09+00:00 app[web.1]: Started GET "/pages/about" for 90.231.141.39 at
2012-01-22T18:26:09+00:00 app[web.1]: cache: [GET /pages/about] miss
2012-01-22T18:26:09+00:00 app[web.1]: ActiveRecord::ConnectionNotEstablished
(ActiveRecord::ConnectionNotEstablished):
This application does not use any database at this point (only presenting static pages). So to me the ActiveRecord error comes as no suprise. Uncertain though if this is the root to the problem. I first thought that this issue was realted to Heroku, since my rails server deployment worked fine, but the I found the rails server -e production command to run the rails server in production environment. Under Rails 3.1.3 this renders the page correctly, but I still get the following error message in the server log:
sample_app$ rails server -e production
=> Booting WEBrick
=> Rails 3.1.3 application starting in production on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2012-01-22 23:07:28] INFO WEBrick 1.3.1
[2012-01-22 23:07:28] INFO ruby 1.9.3 (2011-10-30) [x86_64-darwin11.2.0]
[2012-01-22 23:07:28] INFO WEBrick::HTTPServer#start: pid=57161 port=3000
cache: [GET /] miss
cache: [GET /pages/about] miss
Started GET "/pages/about" for 127.0.0.1 at 2012-01-22 23:09:50 +0100
Processing by PagesController#about as HTML
Rendered pages/about.html.erb within layouts/application (2.0ms)
Completed 200 OK in 24ms (Views: 24.2ms | ActiveRecord: 0.0ms)
cache: [GET /assets/application-cd728f3a08415c27ca2e753d30091c74.css] miss
It seems to me that there is some kind of routing issue. But my lack of knowledge and experience with RoR makes me a lame duck in the search for the actual error.
Upgrading to Rails 3.2.0 made the issue even worse. I made a sample app for Rails 3.2 basically with:
rails new test_app
Entered the "test_app" folder and ran rails server -e production (using Ruby 1.9.3-p0). This time the default Ruby on Rails index page was not even rendered. The server log gives me:
heroku_test$ rails server -e production
=> Booting WEBrick
=> Rails 3.2.0 application starting in production on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2012-01-22 23:19:07] INFO WEBrick 1.3.1
[2012-01-22 23:19:07] INFO ruby 1.9.3 (2011-10-30) [x86_64-darwin11.2.0]
[2012-01-22 23:19:07] INFO WEBrick::HTTPServer#start: pid=63242 port=3000
cache: [GET /] miss
So, it seems in all cases like I have some issues with my routing or my caching or wathever.
These are my specs:
System specs: Mac OS X Lion 10.7.2
Ruby: 1.9.3-p0
Rails: 3.1.3 (and also 3.2.0 release the other day)
I am very aware that these specs are not what Ruby on Rails Tutorial propose. The RoR tutorial is written with the follow Specs in mind:
Ruby: 1.9.2 (or 1.8.7)
Rails: 3.0.11
In chapter 13, Hartl explains the difference with Rails 3.1.x and sports an upgrade guide for the sample_app. I've skimmed through this chapter (since I am stuck at chapter 3) but have been unable to find a remedy to my problems.
What is my question really?
How do I deploy a RoR app to production for a version of RoR that runs on my system?
Related links and sources I've browsed so far, apart from the regular pages on RoR.org and Heroku.com:
cache: [GET /] miss? dalli gem, memcached, rails 3.1, nginx, unicorn production environment
How does one load a CSS framework in Rails 3.1?
rails 3 tutorial: No route matches [GET] “/”
Rails 3.1 on Heroku Cedar
Now that the question has changed:
"What version of Ruby on Rails should I use? Being a newbie to the frameworks, I just want my deployment process to be as smooth as possible."
If you are learning from a book or tutorial, use the same version as the examples in that book/tutorial.
"What about gems mentioned in books and writings? Should I always use the latest one?"
Most gems have dependencies on other gems, so the exact version you use will often depend on those dependencies. Sometimes you may even discover a bug in one version, so you switch to another version to remedy the problem. Or again, if you are following a book/tutorial which uses a certain version, you may want to use the same version (at least while you are working through the tutorial). If, though, you have no good reason to use an old version, then generally you should use the newest one.
Have you learned how to use Bundler? It allows you to control the exact versions of each gem which you want to use.
#jollyCocoa, the error you got when deploying to Heroku was caused by not having the database set up. Even if you're not using the database, if you configure the database connection anyways, it will fix this error. If you are starting with RoR, though, and just want something to experiment with, don't try deploying to Heroku at this point. Just start with a very simple application running locally, even just the "skeleton" application generated by "rails new", and make changes one small step at a time, checking at each step that the app is still working. If you get stuck and can't figure out how to get a certain feature working, you can post a more specific question.

Ruby on Rails new installation on Ubuntu , problem getting a new app to work (TypeError) !

Just installed RoR on Ubuntu 10.10 and created a new app, I get the welcome page, but when I create a simple index page I get TypeError. Here is what I have done:
following instructions available at https://help.ubuntu.com/community/RubyOnRails
Eveything looks fine no error during installation. I opted out for the built in web server to keep things simple.
I created a new app using:
/var/www/$ rails new mynewapp
and started the webserver in terminal:
/var/www/mynewapp/script$ rails server
=> Booting WEBrick
=> Rails 3.0.3 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-02-22 17:14:09] INFO WEBrick 1.3.1
[2011-02-22 17:14:09] INFO ruby 1.8.7 (2010-06-23) [i686-linux]
[2011-02-22 17:14:24] INFO WEBrick::HTTPServer#start: pid=10120 port=3000
I get the welcome page all right. Then I followed the tutorial at (http://guides.rubyonrails.org/getting_started.html) and created my index page:
/var/www/mynewapp$ rails generate controller home index
Then I edited the newlly created mynewapp/views/home/index.html.erb to add a bit of HTML. Then I edited mynewapp/config/routes.rb :
Blog::Application.routes.draw do
#...
# You can have the root of your site routed with "root"
# just remember to delete public/index.html.
root :to => "home#index"
Now when I browse to localhost:3000 instead of the welcome screen I get the following error on the browser:
TypeError
can't convert Fixnum into String
Rails.root: /var/www/mynewapp
and this appears in the terminal:
Started GET "/" for 127.0.0.1 at Wed Feb 23 12:23:17 -0500 2011
TypeError (can't convert Fixnum into String):
Rendered /usr/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.1ms)
Rendered /usr/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (2.1ms)
Rendered /usr/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (6.5ms)
Do you know what am I doing wrong?
Thx
Seems like there are some triubles with database. You can run "rake db:migrate --trace" and post the result, if you still have such problem?
Did you set the database password to be pure digit, like "111111"? My guess I should changed it to be non-numeric like "abcdef", it worked!
Similar to this: Can't convert Fixnum into String - Devise/sessions Controller issue

Resources