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
Rodrigo Muñoz
Courses Plus Student 20,171 PointsBuild a Simple Ruby on Rails Application > Defining Method problems
Hi, I have this problem with the methods. I've realise just after installing "devise" that the example on the video have more code than the one I load with the rails commands. The first problem is about the database > schema file in which old version has this code:
ActiveRecord::Schema.define(:version => 20120724212023) do
create_table "statuses", :force => true do |t|
t.text "content"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "user_id"
end
add_index "statuses", ["user_id"], :name => "index_statuses_on_user_id"
create_table "users", :force => true do |t|
t.string "first_name"
t.string "last_name"´
After I follow the instructions I obtained this code:
ActiveRecord::Schema.define(:version => 20130123202617) do
create_table "statuses", :force => true do |t|
t.string "name"
t.text "content"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "users", :force => true do |t|
t.string "first_name"
t.string "last_name"
So if I keep following the instructions appears this annoying error message "undefined method user_id for #<Status:0x4be0b08>"
I thought it was because of the diference in the database. Well the other problem I got is another syntax problem: undefined method 'full_name' for nil:NilClass.
I actually define this function in the user.rb file as:
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
#Setup accessible (or protected) attributes for your model
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
Could anyone help me with this two problems? I have no idea how to keep going with this
1 Answer
Jason Seifer
Treehouse Guest TeacherHi Rodrigo, try following along with Jim in this video and let us know if you still have problems - http://teamtreehouse.com/library/programming-2/build-a-simple-version-of-facebook/customizing-forms/getting-the-latest-changes.