Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

E Kanna
E Kanna
2,944 Points

Simple Ruby on Rails Basic Application Problem - No clue!

Hi, I'm a complete Ruby newbie and I've been going through the "Build a Simple Ruby on Rails Application" but I seem to have gotten myself completely stuck.. I just finished "Creating Relationships" but now I cannot see the site I've been building when I go to my console and type in http://0.0.0.0:3000/statuses/

This is what I see when I type in "rails server" to the terminal.

=> Booting WEBrick => Rails 4.1.4 application starting in development on http://0.0.0.0:3000 => Run rails server -h for more startup options => Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option) => Ctrl-C to shutdown server Exiting /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:443:in load': /Users/randallkanna/Documents/ruby_projects/demo_app/app/models/user.rb:10: syntax error, unexpected tIDENTIFIER, expecting keyword_end (SyntaxError) from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:443:inblock in load_file' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:633:in new_constants_in' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:442:inload_file' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:342:in require_or_load' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:480:inload_missing_constant' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:180:in const_missing' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/inflector/methods.rb:238:inconst_get' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/inflector/methods.rb:238:in block in constantize' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/inflector/methods.rb:236:ineach' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/inflector/methods.rb:236:in inject' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/inflector/methods.rb:236:inconstantize' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:552:in get' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:583:inconstantize' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/devise-3.2.4/lib/devise.rb:297:in get' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/devise-3.2.4/lib/devise/mapping.rb:77:into' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/devise-3.2.4/lib/devise/mapping.rb:72:in modules' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/devise-3.2.4/lib/devise/mapping.rb:89:inroutes' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/devise-3.2.4/lib/devise/mapping.rb:156:in default_used_route' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/devise-3.2.4/lib/devise/mapping.rb:66:ininitialize' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/devise-3.2.4/lib/devise.rb:331:in new' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/devise-3.2.4/lib/devise.rb:331:inadd_mapping' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/devise-3.2.4/lib/devise/rails/routes.rb:221:in block in devise_for' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/devise-3.2.4/lib/devise/rails/routes.rb:220:ineach' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/devise-3.2.4/lib/devise/rails/routes.rb:220:in devise_for' from /Users/randallkanna/Documents/ruby_projects/demo_app/config/routes.rb:2:inblock in <top (required)>' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.4/lib/action_dispatch/routing/route_set.rb:337:in instance_exec' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.4/lib/action_dispatch/routing/route_set.rb:337:ineval_block' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.4/lib/action_dispatch/routing/route_set.rb:315:in draw' from /Users/randallkanna/Documents/ruby_projects/demo_app/config/routes.rb:1:in<top (required)>' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:241:in load' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:241:inblock in load' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:232:in load_dependency' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:241:inload' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/application/routes_reloader.rb:40:in block in load_paths' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/application/routes_reloader.rb:40:ineach' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/application/routes_reloader.rb:40:in load_paths' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/application/routes_reloader.rb:16:inreload!' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/application/routes_reloader.rb:26:in block in updater' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/file_update_checker.rb:75:incall' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/file_update_checker.rb:75:in execute' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/application/routes_reloader.rb:27:inupdater' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/application/routes_reloader.rb:7:in execute_if_updated' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/application/finisher.rb:71:inblock in <module:Finisher>' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/initializable.rb:30:in instance_exec' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/initializable.rb:30:inrun' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/initializable.rb:55:in block in run_initializers' from /Users/randallkanna/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:226:inblock in tsort_each' from /Users/randallkanna/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:348:in block (2 levels) in each_strongly_connected_component' from /Users/randallkanna/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:427:ineach_strongly_connected_component_from' from /Users/randallkanna/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:347:in block in each_strongly_connected_component' from /Users/randallkanna/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:345:ineach' from /Users/randallkanna/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:345:in call' from /Users/randallkanna/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:345:ineach_strongly_connected_component' from /Users/randallkanna/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:224:in tsort_each' from /Users/randallkanna/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:205:intsort_each' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/initializable.rb:54:in run_initializers' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/application.rb:300:ininitialize!' from /Users/randallkanna/Documents/ruby_projects/demo_app/config/environment.rb:5:in <top (required)>' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:inrequire' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:in block in require' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:232:inload_dependency' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:in require' from /Users/randallkanna/Documents/ruby_projects/demo_app/config.ru:3:inblock in <main>' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/rack-1.5.2/lib/rack/builder.rb:55:in instance_eval' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/rack-1.5.2/lib/rack/builder.rb:55:ininitialize' from /Users/randallkanna/Documents/ruby_projects/demo_app/config.ru:in new' from /Users/randallkanna/Documents/ruby_projects/demo_app/config.ru:in<main>' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/rack-1.5.2/lib/rack/builder.rb:49:in eval' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/rack-1.5.2/lib/rack/builder.rb:49:innew_from_string' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/rack-1.5.2/lib/rack/builder.rb:40:in parse_file' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/rack-1.5.2/lib/rack/server.rb:277:inbuild_app_and_options_from_config' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/rack-1.5.2/lib/rack/server.rb:199:in app' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/commands/server.rb:50:inapp' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/rack-1.5.2/lib/rack/server.rb:314:in wrapped_app' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/commands/server.rb:130:inlog_to_stdout' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/commands/server.rb:67:in start' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/commands/commands_tasks.rb:81:inblock in server' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/commands/commands_tasks.rb:76:in tap' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/commands/commands_tasks.rb:76:inserver' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/commands/commands_tasks.rb:40:in run_command!' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/commands.rb:17:in<top (required)>' from /Users/randallkanna/Documents/ruby_projects/demo_app/bin/rails:8:in require' from /Users/randallkanna/Documents/ruby_projects/demo_app/bin/rails:8:in<top (required)>' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/client/rails.rb:27:in load' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/client/rails.rb:27:incall' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/client/command.rb:7:in call' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/client.rb:26:inrun' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/bin/spring:48:in <top (required)>' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/binstub.rb:11:inload' from /Users/randallkanna/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/binstub.rb:11:in <top (required)>' from /Users/randallkanna/Documents/ruby_projects/demo_app/bin/spring:16:inrequire' from /Users/randallkanna/Documents/ruby_projects/demo_app/bin/spring:16:in <top (required)>' from bin/rails:3:inload' from bin/rails:3:in `<main>'

Additionally, this is the code that seemed to start the problem as far as I could tell.

# this is in my user.rb file
class User < ActiveRecord::Base
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable

         attr_accessible :email, :password, :password_confirmation, :remember_me, :first_name, :last_name, :profile_name

         has_many :statuses

    def full_name
        first_name  + " " last_name
    end

end

Additionally, this is the code in my index file.

<div class="page-header">
  <h1> Statuses </h1>
</div>

<%= link_to "Post a New Status", new_status_path, class: "btn btn-info" %>

  <% @statuses.each do |status| %>
    <div class="status">
      <strong> <%= status.user.full_name %> </strong>
      <p><%= status.content %></p>
      <div class="meta">
        <%= link_to time_ago_in_words(status.created_at) + " ago" , status %>

            <span class="admin">
                <%= link_to "Show", status %>
              | <%= link_to "Edit", edit_status_path(status) %> |
              <%= link_to "Delete", status, method: :delete, data: {confirm: "Are you sure you want to delete this status?"} %>

            </span>

      </div>

      </div>
  <% end %>

  ```
Any help is much appreciated!

4 Answers

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

Yeah, this app will not work if you're using Rails 4.1.4. Your forms won't send info to the database, so you will deal with nil:NilClass a lot. Please refer to my answer here:

https://teamtreehouse.com/forum/hello-i-get-stuck-at-this-point

and then here:

https://teamtreehouse.com/forum/validates-firstname-presence-true-not-working

E Kanna
E Kanna
2,944 Points

Thank you! I was trying to convert but I think I'll just switch to the other version of Rails. Thanks again!

E Kanna
E Kanna
2,944 Points

Fixed my own problem by running all of these commands..

rake db:reset Status.delete_all User.delete_all

E Kanna
E Kanna
2,944 Points

Alright, seemed to have fix that issue as far as I can tell.. But now this is coming up instead and I can't seem to see the 3000 site thing at all....

NoMethodError in Statuses#index Showing /Users/randallkanna/Documents/ruby_projects/demo_app/app/views/statuses/index.html.erb where line #10 raised:

undefined method `full_name' for nil:NilClass Extracted source (around line #10): 7 8 9 10 11 12 13

 <% @statuses.each do |status| %>
   <div class="status">
     <strong> <%= status.user.full_name %> </strong>
     <p><%= status.content %></p>
     <div class="meta">
       <%= link_to time_ago_in_words(status.created_at) + " ago" , status %>

def full_name first_name + " " last_name end

missing the "+" after the " "

BTW I am also having the issue on Rails 4.1.4 Im getting full_name as nill class