WEBRIck not booting up..getting error message - ruby-on-rails

Here is the new error message I am getting when doing rails s....
Exiting
C:/Sites/ThinkBlog/crumblr/config/initializers/devise.rb:235:in block
in <top (required)>': undefined method[]' for nil:NilClass
(NoMethodError) from
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/devise-3.3.0/lib/devise.rb:292:in
setup' from
C:/Sites/ThinkBlog/crumblr/config/initializers/devise.rb:3:in<top
(required)>' from
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:241:in `load'
By the way line 235 in device.rb is ,
config.omniauth :facebook, FACEBOOK_CONFIG['facebook_api_key'], FACEBOOK_CONFIG['facebook_api_secret']

The error messages tells you exactly what is wrong with your code: undefined method[]' for nil or in other words: You try to call the [] method on an object the is nil.
Since you only call [] on FACEBOOK_CONFIG the only reason for this errors is: FACEBOOK_CONFIG is not initialized and therefore nil.

Related

NoMethodError: undefined method `create_reset_digest' for #<User:0x007fba32e0af58>

I got these 5 errors upon doing a bundle rake exec test. I have no idea how to resolve it. I've googled and googled with no end in site (see what I did there). Now I turn to you for help!
If you accept, these are the errors:
1) Error:
PasswordResetsTest#test_password_resets:
NoMethodError: undefined method `create_reset_digest' for #<User:0x007fba32e0af58>
app/controllers/password_resets_controller.rb:12:in `create'
test/integration/password_resets_test.rb:17:in `block in <class:PasswordResetsTest>'
2) Error:
UsersLoginTest#test_login_with_valid_information_followed_by_logout:
ActionView::Template::Error: undefined method `current_user?' for #<#<Class:0x007fba2cdf19a0>:0x007fba28cd32c0>
app/views/microposts/_micropost.html.erb:10:in `_app_views_microposts__micropost_html_erb___3978616761423832463_70218762096200'
app/views/users/show.html.erb:15:in `_app_views_users_show_html_erb___2170813965465965459_70218768032700'
test/integration/users_login_test.rb:14:in `block in <class:UsersLoginTest>'
3) Error:
UsersProfileTest#test_profile_display:
ActionView::Template::Error: undefined method `current_user?' for #<#<Class:0x007fba2cdf19a0>:0x007fba2f8c51e0>
app/views/microposts/_micropost.html.erb:10:in `_app_views_microposts__micropost_html_erb___3978616761423832463_70218762096200'
app/views/users/show.html.erb:15:in `_app_views_users_show_html_erb___2170813965465965459_70218768032700'
test/integration/users_profile_test.rb:11:in `block in <class:UsersProfileTest>'
4) Error:
UsersIndexTest#test_index_as_admin_including_pagination_and_delete_links:
ActionView::Template::Error: undefined method `current_user?' for #<#<Class:0x007fba2cdf19a0>:0x007fba28ed08e8>
app/views/users/_user.html.erb:4:in `_app_views_users__user_html_erb__3013593760514997339_70218798383040'
app/views/users/index.html.erb:7:in `_app_views_users_index_html_erb___1851646122892737362_70218763684120'
test/integration/users_index_test.rb:12:in `block in <class:UsersIndexTest>'
5) Error:
MicropostsInterfaceTest#test_micropost_interface:
ActionView::Template::Error: undefined method `current_user?' for #<#<Class:0x007fba312ac360>:0x007fba2ff66120>
app/views/microposts/_micropost.html.erb:10:in `_app_views_microposts__micropost_html_erb___3978616761423832463_70218762096200'
app/views/shared/_feed.html.erb:3:in `_app_views_shared__feed_html_erb___1999510692289199836_70218832039180'
app/views/static_pages/home.html.erb:13:in `_app_views_static_pages_home_html_erb__315324690869897794_70218832802580'
test/integration/microposts_interface_test.rb:11:in `block in <class:MicropostsInterfaceTest>'
BACKSTORY: I ignored these errors messages as I went through a few of the chapters. I'm not sure if it popped up between 9, 10, or 11. I am new to programming so I don't know if this is enough information for you to be able to help me. The deeper I get into programming material the more it all seems confusing. SOS
I suppose you are following the https://www.railstutorial.org
You have a recurring undefined method 'current_user' error in [2, 3, 4, 5]
Did you defined the current_user helper method as it should be done in your session_helper.rb ?

User.pins is giving me error in Rails Console

I am running into an error on Rails Console. When I type user.pins, I receive an error. Below is the text in the console that I get. Any help is appreciated, thanks!
2.1.2 :008 > user.pins
NoMethodError: undefined method pins' for #<User:0x007fa029493808>
from /Users/jovanhernandez/.rvm/gems/ruby-2.1.2/gems/activemodel-4.1.6/lib/active_model/attribute_methods.rb:435:inmethod_missing'
from /Users/jovanhernandez/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.6/lib/active_record/attribute_methods.rb:211:in method_missing'
from (irb):8
from /Users/jovanhernandez/.rvm/gems/ruby-2.1.2/gems/railties-4.1.6/lib/rails/commands/console.rb:90:instart'
from /Users/jovanhernandez/.rvm/gems/ruby-2.1.2/gems/railties-4.1.6/lib/rails/commands/console.rb:9:in start'
from /Users/jovanhernandez/.rvm/gems/ruby-2.1.2/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:69:inconsole'
from /Users/jovanhernandez/.rvm/gems/ruby-2.1.2/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:40:in run_command!'
from /Users/jovanhernandez/.rvm/gems/ruby-2.1.2/gems/railties-4.1.6/lib/rails/commands.rb:17:in'
from bin/rails:8:in require'
from bin/rails:8:in'

Error instantiating mechanize object

I have no idea what the problem is on this. I'm trying this in the rails console:
>> agent = Mechanize.new
NoMethodError: undefined method `user' for nil:NilClass
I added gem 'mechanize' and did a bundle install. I did require 'mechanize'. I also tried require 'nokogiri' below that, and every time I get the same error. I've tried 4 or 5 different ways to instantiate a new mechanize object and haven't been able to find one.
I searched my entire rails app for the string '.user' and couldn't find any. Not sure what the deal is here. Any ideas?
Thanks
EDIT
Full Stack trace
NoMethodError: undefined method `user' for nil:NilClass
from /home/me/.rvm/gems/ruby-1.9.3-p448#my_app/gems/net-http-persistent-2.9.2/lib/net/http/persistent.rb:866:in `proxy='
from /home/me/.rvm/gems/ruby-1.9.3-p448#my_app/gems/mechanize-2.7.2/lib/mechanize/http/agent.rb:1189:in `set_proxy'
from /home/me/.rvm/gems/ruby-1.9.3-p448#my_app/gems/mechanize-2.7.2/lib/mechanize.rb:204:in `initialize'
from (irb):5:in `new'
from (irb):5
from /home/me/.rvm/gems/ruby-1.9.3-p448#global/gems/railties-3.2.15/lib/rails/commands/console.rb:47:in `start'
from /home/me/.rvm/gems/ruby-1.9.3-p448#global/gems/railties-3.2.15/lib/rails/commands/console.rb:8:in `start'
from /home/me/.rvm/gems/ruby-1.9.3-p448#global/gems/railties-3.2.15/lib/rails/commands.rb:41:in `<top (required)>'
from /home/me/Dropbox/Work/RubymineProjects/apps/my_app/script/rails:6:in `require'
from /home/me/Dropbox/Work/RubymineProjects/apps/my_app/script/rails:6:in `<top (required)>'
from -e:1:in `load'
from -e:1:in `<main>'
You're not doing anything wrong: the version of mechanize that came out a few days ago is buggy. I solved that error just updating the gem (i.e., with bundle update mechanize).

Class method returning NoMethodError: undefined method Rails

I am writing a class method to find certain data in my database however I am getting a NoMethodError: undefined method error. I am using Datamapper instead of ActiveRecord. Here is my error output:
NoMethodError: undefined method `get_courses_starting_in' for Course:Class
from /Users/hugo/.rvm/gems/ruby-1.9.2-p318/gems/dm-ar-finders-1.2.0/lib/dm-ar-finders.rb:155:in `method_missing_with_find_by'
from /Users/hugo/Web Development/Rails/connectedtrips/lib/ct_gems/dm-core-1.2.0/lib/dm-core/model/relationship.rb:372:in `method_missing'
from /Users/hugo/Web Development/Rails/connectedtrips/lib/ct_gems/dm-core-1.2.0/lib/dm-core/model/property.rb:249:in `method_missing'
from (irb):24
from /Users/hugo/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/commands/console.rb:47:in `start'
from /Users/hugo/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/commands/console.rb:8:in `start'
from /Users/hugo/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
And here is my class method:
def self.get_courses_starting_in
courses = []
Course.all.each{ |course| courses << course if course.days_till_course_starts == 7}
return courses
end
I hope someone can help. Thanks.
Have you write the code after starting the console? Restart console and check again.

config.action_controller.asset_path_template -- undefined method?

I'm trying to use:
https://github.com/polleverywhere/asset_fingerprinter
To install for Rails 3 you need to set:
config.action_controller.asset_path_template = AssetFingerprinter.path_rewriter
But that errors with:
.rvm/gems/ruby-1.9.2-p180#andyw/gems/actionpack-3.0.5/lib/action_controller/railtie.rb:54:in `block (3 levels) in <class:Railtie>': undefined method `asset_path_template=' for ActionController::Base:Class (NoMethodError)
Any ideas?
Thanks
I believe asset_path_template is not a method but a member in a hash
Try config.action_controller["asset_path_template"]

Resources