i'm playing around trying to create a website where people can upload their property. i've created a new model and controller where people can do this. The data is successfully saved to the database, but it won't display on the show page. All of the fields return blank.
Started POST "/investments" for 127.0.0.1 at 2018-02-16 11:17:37 +1000
(6.7ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
ORDER BY "schema_migrations"."version" ASC
Processing by InvestmentsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"r2WOptmoB7Icoal2SHVBTjyhiaLBKoBMydxIyLbiOr6lTs6UVvs0fvuj3TS2whDpLYouGYkWzP1AEg/GghbJAQ==", "investment"=>{"title"=>"test", "description"=>"test", "propertytype"=>"test", "bedrooms"=>"test", "carpark"=>"test", "landsize"=>"test", "equity"=>"test", "cashflow"=>"test", "rating"=>"test"}, "commit"=>"Save Investment"}
show.html.erb
<strong>Title:</strong>
<%= @investment.title %>
<%= @investment.excerpt %>
<%= @investment.description %>
<%= @investment.propertytype %>
<%= @investment.bedrooms %>
<%= @investment.carpark %>
<%= @investment.landsize %>
<%= @investment.equity %>
<%= @investment.cashflow %>
<%= @investment.rating %>
investments_controller.erb
class InvestmentsController < ApplicationController
def show
@investment = Investment.new(params.permit(:title, :excerpt, :description, :propertytype, :bedrooms, :carpark, :landsize, :equity, :cashflow, :rating))
end
def new
end
def create
@investment = Investment.new
@investment.save
redirect_to @investment
end
private
def investment_params
params.permit(:title, :excerpt, :description, :propertytype, :bedrooms, :carpark, :landsize, :equity, :cashflow, :rating)
end
end
routes.rb
Rails.application.routes.draw do
mount Ckeditor::Engine => '/ckeditor'
get 'pages/index' => 'high_voltage/pages#show', id: 'index'
root :to => 'high_voltage/pages#show', id: 'index'
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
resources :investments
end
here's the final result^