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 Build a Simple Ruby on Rails Application Frontend Development Updating the Index Page

Receiving "NoMethodError in Statuses#index"

Hey Guys,

Here is my code within my index.html.erb... ```<div class="page-header"> <h1>All of the Statuses</h1> </div>

<% @statuses.each do |status| %> <div class="status"> <strong><%= status.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 "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 %>```

I'm receiving an error from my rails server that there is no method defined for "Content", the code in question specifically being that located on line 8.

I'm using ruby 2.1.2 and rails 4.1.1

Thanks for your patience and assistance!

Evan

8 Answers

Naomi Freeman
STAFF
Naomi Freeman
Treehouse Guest Teacher

attr_accessible doesn't exist in Rails 4 :) It's been replaced by strong params.

https://teamtreehouse.com/forum/rails-404

(just disregard all the haters who want you to downgrade to Rails 3. No point in doing that - you'll need to fix these same things "in real life")

Naomi Freeman
STAFF
Naomi Freeman
Treehouse Guest Teacher

Well, does your status have content or is it defined as something else? lol

May we see your full app?

I'm interested in seeing

db

  • schema.rb

In there, look for statuses and see which columns are defined. Maybe your content is called tweet or something, you know?

And also, in your statuses controller,

at the bottom, in your .permit, have you allowed (:content)?

Did you set up attr_accessible or do the correct .permit for Rails 4?

Difficult to troubleshoot without seeing the rest of the code :)

Hey Summer,

I feel like a dumby, it was a small error in my index.html.erb code where I had improperly written a part of my status loop.

Thanks!

Evan

Naomi Freeman
STAFF
Naomi Freeman
Treehouse Guest Teacher

lol no problem. Everyone needs to step away from their code for a second every now and then :)

That's the real reason these tech companies all have ping pong tables.

Haha so true!

I'm curious Summerspirit, I'm having this issue where when I haven't been able to upload again to git hub.

When I set git push, I receive this error in the terminal...

To https://github.com/lazerbass/treebook.git ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'https://github.com/lazerbass/treebook.git' To prevent you from losing history, non-fast-forward updates were rejected Merge the remote changes (e.g. 'git pull') before pushing again. See the 'Note about fast-forwards' section of 'git push --help' for details.

I'm doing some homework on "fast-forwards" but you seem very knowledgeable and I would be grateful for any insight that you have.

Best,

Evan

Naomi Freeman
STAFF
Naomi Freeman
Treehouse Guest Teacher

Sorry I wasn't around last night. Ended up out.

Basically it's saying the master branch you have locally, at the place you started editing, does not have changes that happened to the master branch that is remote.


The short answer is: there are changes remote that you don't have locally. Git is asking your permission to screw up your file if you have changed the same piece of code locally as something remote. That's ok though. Unless it's an image, pretty much it'll just be this weird thing in your code that looks like this:

<<<<<<< HEAD Changes made on the branch that is being merged into. In most cases, this is the branch that I have currently checked out (i.e. HEAD). |||||||

The common ancestor version.

Changes made on the branch that is being merged in. This is often a feature/topic branch.

If you (on mac) command + shift + F in sublime text, you can pull up a search that will search your whole code. Just search HEAD and you can find them all.

What that weird chunk is doing is showing you the two versions of code, separated by ====. You pick the one you want, erase the other one and all the >>>> ===, then commit again and push that. Merge conflict fixed manually.


Working on your own, you shouldn't have to pull, unless someone forks your repo and makes some changes you want to incorporate.


In your current situation, just git pull and it might

  1. merge on its own or
  2. trap you in a white terminal screen you don't know how to get out of On mac, what you do with that screen is

  3. just start typing a message. Any message. It should be relevant to what's being merged, but if it's nonsense, write that.

  4. ctrl + X

  5. y (don't make it capital. don't touch any other buttons)

  6. enter

Then git push.


Hope that helps?

Thanks! By pulling it has merged on it's own.

I got another one for you : )

After entering and saving my attr_accessible items into user.rb under models, when I attempt to reboot my rails server, it immediately exits and I receive the error for attr_accessible method undefined error.

Here's my user.rb code...

```class User < ActiveRecord::Base # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable

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

end```

What are your thoughts my friend?

Ruby -v 2.1.2 Rails -v 4.1.1

Best!

Evan

I thought that version differentiation was going to be the issue.

Thanks mate!