ruby on rails - Letting Pin select one Category -
i have problem letting pin select 1 category, below had attempted.
$ rails g model category name:string $ rails g migration add_category_id_to_event in /db/migrate/xxxx_add_category_id_to_pin
i modified
class addcategoryidtopin < activerecord::migration def self.up add_column :pins, :category_id, :integer end def self.down remove_column :pin, :category_id end end rake db:migrate
in app/models/pin.rb
class event < activerecord::base belongs_to :category end
in app/models/category.rb
class category < activerecord::base has_many :pins end
in rails console
category.create( :name => "course" ) category.create( :name => "meeting" ) category.create( :name => "conference" )
in app/views/pins/_form.html.erb
<%= f.select :category_id, category_options %>
in pp/views/pins/show.html.erb
<p>category: <%= @pin.category.name %><p>
in app/helpers/pins_helper.rb
module pinshelper def category_options category.all.map{ |c| [c.name, c.id] } end end
but nothing shows on app , below, before working fine. don't understand went wrong? can 1 help?
nameerror in pins#index
showing /users/mattbook/code/dine/app/views/layouts/_header.html.erb line #17 raised:
undefined local variable or method `new_pin_path' #<#:0x007f92565413d0> extracted source (around line #17):
14:
15: 16: 17: <% if user_signed_in? %>
Comments
Post a Comment