【发布时间】:2014-09-30 03:41:16
【问题描述】:
在数据库设置终端命令“rails server”成功执行后,我正在为我的本地机器设置一个现有的“Ruby On Rails”项目,但是当我在浏览器中点击 localhost:3000 时,我得到以下响应......
Started GET "/" for 127.0.0.1 at 2014-04-08 16:07:01 +0530
Processing by ContentController#index as HTML
RvClass Load (0.1ms) SELECT "rv_classes".* FROM "rv_classes"
Testimonial Load (0.2ms) SELECT "testimonials".* FROM "testimonials" WHERE "testimonials"."approved" = 't'
Setting Load (0.2ms) SELECT "settings".* FROM "settings" LIMIT 1
Completed 500 Internal Server Error in 1136ms
NoMethodError (undefined method `features' for nil:NilClass):
app/controllers/content_controller.rb:18:in `index'
content_controller.rb:
class ContentController < ApplicationController
layout "application"
before_filter :check_for_mobile, :except => [:inventory, :disclaimer, :preowned, :sunridge_rv_video]
before_filter :prepare_for_mobile, :only => [:inventory, :social_media ]
def inventory
end
def social_media
end
def index
@tweets = begin
Twitter.user_timeline("sunridgeRV").slice(0, 6)
rescue Twitter::Error
[]
end
@feature_products = Setting.first.features.where("product_id is not null")
@home_page_testimonials = Testimonial.where(:approved=>true).shuffle.take(3)
@setting = Setting.first
@products = Product.where(special_on_homepage: true)
end
def disclaimer
render :partial => 'disclaimer'
end
def preowned
render :partial => 'used_guarantee'
end
def sunridge_rv_video
@rv_class_brands = RvClassBrand.has_video_link
end
def sunridge_team
@team_members = TeamMember.order("department_id").order("id")
end
def sales_home
@setting = Setting.first
end
end
【问题讨论】:
-
发布您的
content_controller代码 -
你好@Pavan 我已经添加了我的内容控制器代码请看一下...
-
Setting好像没有记录,所以报错。检查Setting中是否存在记录 -
你跑
rake db:seed了吗? -
是的@Pavan 我也认为没有记录但是我如何将数据导入我的数据库我不知道我是 ROR 的初学者......
标签: ruby-on-rails ruby setup-project