是不是哪里还有没有添加的?
Banlab rails c
Loading development environment (Rails 3.2.6)
1.9.3-p194 :001 > Admin.column_names
=> ["id", "email", "encrypted_password", "reset_password_token", "reset_password_sent_at", "remember_created_at", "sign_in_count", "current_sign_in_at", "last_sign_in_at", "current_sign_in_ip", "last_sign_in_ip", "created_at", "updated_at", "name"]
1.9.3-p194 :002 >
class Admin < 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, :name
# attr_accessible :title, :body
end
p#notice
= notice
article
header
h1 = @blog.title
= timeago_tag @blog.created_at, nojs:true, limit:10.days.ago, class:"post_at_time"
span created_by #{@admin.name}
= simple_format(@blog.content)
- if admin_signed_in?
footer.nav
ul.group
li.group
= link_to 'Edit', edit_blog_path(@blog)
li.group
= link_to 'Destroy', @blog, method: :delete, data: {confirm:"I'm Really Sure?"}
li.group
= link_to "Cancel", blogs_path
NoMethodError in Blogs#show
Showing /Users/yuwen/Documents/bitbucket/Banlab/app/views/blogs/show.html.slim where line #8 raised:
undefined method `name' for nil:NilClass
Extracted source (around line #8):
5: header
6: h1 = @blog.title
7: = timeago_tag @blog.created_at, nojs:true, limit:10.days.ago, class:"post_at_time"
8: span Created by #{@admin.name}
9: = simple_format(@blog.content)
10: - if admin_signed_in?
11: footer.nav