Can't see why I'm getting undefined method form_for

Richlewis

I don't get why I'm getting this error

undefined method `sector_id' for #<Portfolio:0x007fe17c2e3848>

I have a Portfolio Model and a Sector model, they look like so

class Portfolio < ActiveRecord::Base
  belongs_to :sector
  attr_accessible :overview, :title, :sector_id
end



class Sector < ActiveRecord::Base
  has_many :portfolios
  attr_accessible :name
end

My routes

resources :portfolios do
  resources :sectors
end

So within my form to create a new portfolio I have this collection_select

<%= f.label :sector_id, "Choose Sector", :class => 'title_label' %><br>
<%= f.collection_select(:sector_id, Sector.all, :id, :name, :prompt => "Please Select a Sector") %>

This is something I've done many times before and it has worked, can anyone see why I would be getting this error?

The only thing I can think of is that I have called my controller for portfolio as Portfolios, I always get mixed up with plural and singular controller names, would this make a difference in my case?

p.matsinopoulos

Maybe you have not run the migration yet that adds the column "sector_id" in your table "portfolios". If you are using MySQL connect to your database and check the table (show create table portfolios;). Use appropriate method to get this info from your database server if you are using other rdbms. Alternatively, in your rails console (rails c) type in Portofolio and see what attributes it prints out. Does it include sector_id?

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

I'm using iron:router v1.0.7 but this.render() is "undefined". I can't see what I'm doing wrong

분류에서Dev

Why can't I see gnome extensions?

분류에서Dev

why I can't see the interface in Linux Debian

분류에서Dev

Why I can't see port opened by a process in file descriptors?

분류에서Dev

Copy-item failing without error, I'm sure it's something simple but I can't see it

분류에서Dev

Why can not I see the screen output consecutively?

분류에서Dev

Why can't I set an object to null in an extension method

분류에서Dev

I'm Working with a button command, but can't see what's wrong with this code using elseif statements

분류에서Dev

Why can't I see a QXL device in my windows 10 kvm guest

분류에서Dev

I keep getting segmentation fault :11 errors and i can't figure out why... c++

분류에서Dev

I see borders in high contrast mode even if I don't specify any borders to form input fields. why?

분류에서Dev

In R, how can I see the signatures for which a generic method is implemented?

분류에서Dev

Why do I keep getting this "undefined reference" error?

분류에서Dev

I have no idea why im getting a "undefined is not a function" error

분류에서Dev

Why can't a user see a specific directory in public folder in outlook?

분류에서Dev

Why others can't see my wordpress website

분류에서Dev

Using form_for with nested resources. "Undefined method _index_path"

분류에서Dev

Why can't I get the RESTful Web Service response? GET method

분류에서Dev

Why I can not override WebView 'copy:' method?

분류에서Dev

I'm not getting a method description in swagger.json

분류에서Dev

Why I can't rotate the Player transform?

분류에서Dev

Why can't I pgrep a process?

분류에서Dev

Why can't I draw elements to the stage?

분류에서Dev

Why can't I use for in makefile on Windows?

분류에서Dev

Why can't I create a Jenkins account?

분류에서Dev

Why I can't select MF?

분류에서Dev

Why can't I write to the file mmaped

분류에서Dev

Why can't I delete this directory?

분류에서Dev

Why can't I change the value in GridView?

Related 관련 기사

  1. 1

    I'm using iron:router v1.0.7 but this.render() is "undefined". I can't see what I'm doing wrong

  2. 2

    Why can't I see gnome extensions?

  3. 3

    why I can't see the interface in Linux Debian

  4. 4

    Why I can't see port opened by a process in file descriptors?

  5. 5

    Copy-item failing without error, I'm sure it's something simple but I can't see it

  6. 6

    Why can not I see the screen output consecutively?

  7. 7

    Why can't I set an object to null in an extension method

  8. 8

    I'm Working with a button command, but can't see what's wrong with this code using elseif statements

  9. 9

    Why can't I see a QXL device in my windows 10 kvm guest

  10. 10

    I keep getting segmentation fault :11 errors and i can't figure out why... c++

  11. 11

    I see borders in high contrast mode even if I don't specify any borders to form input fields. why?

  12. 12

    In R, how can I see the signatures for which a generic method is implemented?

  13. 13

    Why do I keep getting this "undefined reference" error?

  14. 14

    I have no idea why im getting a "undefined is not a function" error

  15. 15

    Why can't a user see a specific directory in public folder in outlook?

  16. 16

    Why others can't see my wordpress website

  17. 17

    Using form_for with nested resources. "Undefined method _index_path"

  18. 18

    Why can't I get the RESTful Web Service response? GET method

  19. 19

    Why I can not override WebView 'copy:' method?

  20. 20

    I'm not getting a method description in swagger.json

  21. 21

    Why I can't rotate the Player transform?

  22. 22

    Why can't I pgrep a process?

  23. 23

    Why can't I draw elements to the stage?

  24. 24

    Why can't I use for in makefile on Windows?

  25. 25

    Why can't I create a Jenkins account?

  26. 26

    Why I can't select MF?

  27. 27

    Why can't I write to the file mmaped

  28. 28

    Why can't I delete this directory?

  29. 29

    Why can't I change the value in GridView?

뜨겁다태그

보관