vendredi 27 février 2015

Rails: number_field isn't showing up when outputting a form?

I have a basic form at the moment, I inserted a it has a title, body and a number_field. All three of them are working it seems, except when I go to my index to view the posts only the title and body show up, no number.


the controller: class AuctionsController < ApplicationController



def index
@auctions = Auction.all
end

def new
@auctions = Auction.new
end

def create
@auctions = Auction.new(auction_params)
if @auctions.save
redirect_to auctions_path
else
render "new"
end
end


def destroy
@auctions = Auction.find(params[:id])
@auctions.destroy
redirect_to auctions_path
end


private
def auction_params
params.require(:auction).permit(:title, :details)
end

end


_form.html.erb



<%= form_for Auction.new do |f| %>
<%= f.text_field :title %> <br>
<%= f.text_area :details %> <br>
<%= f.number_field :price %> <br>
<%= f.submit "Submit" %>
<% end %>


and my index.html.erb



<% @auctions.each do |auction| %>
<%= auction.title %> <br>
<%= auction.details %> <br>
<%= auction.price %> <br>
<%= link_to "Delete", auction, :method => :delete %>
<% end %>

Aucun commentaire:

Enregistrer un commentaire