http://i.imgur.com/KUCPEki.png
当我尝试输入报告时(约为video tutorial的1:19标记),它们只是显示为空白(见上图)。当我尝试编辑它们时,编辑页面显示空白字段。可能导致此问题的原因是什么?我将我的模型命名为#34; Report"与用户相反,但是在教程之后也是如此。以下是我的宝石文件,感谢您提供的任何帮助:)
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.4'
gem 'devise'
gem 'protected_attributes'
# Use sqlite3 as the database for Active Record
group :development do
gem 'sqlite3'
end
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.2'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
gem 'geocoder'
gem 'gmaps4rails'
group :production do
gem 'pg', '0.15.1'
gem 'rails_12factor', '0.0.2'
end
编辑:报告控制器代码
class ReportsController < ApplicationController
before_action :set_report, only: [:show, :edit, :update, :destroy]
# GET /reports
# GET /reports.json
def index
@reports = Report.all
end
# GET /reports/1
# GET /reports/1.json
def show
end
# GET /reports/new
def new
@report = Report.new
end
# GET /reports/1/edit
def edit
end
# POST /reports
# POST /reports.json
def create
@report = Report.new(report_params)
respond_to do |format|
if @report.save
format.html { redirect_to @report, notice: 'Report was successfully created.' }
format.json { render action: 'show', status: :created, location: @report }
else
format.html { render action: 'new' }
format.json { render json: @report.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /reports/1
# PATCH/PUT /reports/1.json
def update
respond_to do |format|
if @report.update(report_params)
format.html { redirect_to @report, notice: 'Report was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @report.errors, status: :unprocessable_entity }
end
end
end
# DELETE /reports/1
# DELETE /reports/1.json
def destroy
@report.destroy
respond_to do |format|
format.html { redirect_to reports_url }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_report
@report = Report.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def report_params
params.require(:report).permit(:latitude, :longitude, :address, :description, :photo, :title, :text)
end
end