I'm creating a simple site with Ruby on Rails, and I want to be able to register information such as member addresses in the Address table separately from the member table.
NoMethodError (undefined method `permit'for" form input value ": String): I would like to ask you to teach me because the error is occurring and the cause is unknown.
Corresponding source code
NoMethodError (undefined method `permit'for" form input value ": String): app/controllers/customers/addresses_controller.rb: 22: in `address_params' app/controllers/customers/addresses_controller.rb: 6: in `create'
def create @address = Address.new (address_params) @ address.save rediect_to addresses_path end private def address_params params.require (: address) .permit (: name,: post_code,: address) end
Delivery address <% = form_with (model: @address, url: addresses_path (@address)) do | f |%> <% = f.label: Zip Code%> <br> <% = f.text_field: post_code%> <br> <% = f.label: Address%> <br> <% = f.text_field: address%> <br> <% = f.label: Name%> <br> <% = f.text_field: name%> <br> <% = f.submit'submit'%> <% end%>
create_table "addresses", force:: cascade do | t | t.integer "customer_id", null: false t.string "name", null: false t.string "post_code", null: false t.string "address", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false end
What I tried
scope module :: customers do resources: addresses, except: [: new,: show] end
I wondered if the column name was wrong and confirmed it, but there seemed to be no problem.
I also confirmed spelling mistakes, but there were no problems.
Rails -v 18.104.22.168
Answer # 1
Probably because the contents of params are not posted.
I'm sorry if I made a mistake.
This seems to fly the data to the controller, so
Is there a problem with params or params.require (: address)?
I think it's probably the latter.
Please check the inside of params once with binding.pry etc.
Also, even if this error is resolved, you may still get an error at @ address.save.
Because there is no customer_id.
How is it?
- ruby on rails: nomethoderror that occurred when adding a good function
- ruby on rails: about nomethoderror that occurred when adding a good function
- ruby on rails - i want to eliminate nomethoderror
- ruby on rails 6 - [error] nomethoderror in communitiescontroller # create undefined method `published?'for # <community: 0x0
- ruby on rails 6 - i want to solve the error that occurred while implementing the product listing function
- ruby - i'm having trouble with rails nomethoderror (i want to get data with each method!)
- ruby on rails - nomethoderror in itemscontroller # new error
- ruby on rails - an error has occurred, all later migrations canceled: mysql2 :: error: table'likes' already exists
- ruby on rails 6 - [error] nomethoderror in followscontroller # destroy undefined method `destroy'for nil: nilclass
- ruby on rails - nomethoderror in skils # new
- ruby on rails - nomethoderror in mypage # profile undefined method `username’ for nil: nilclass
- ruby on rails - rails6 rspec model run-time error nomethoderror: undefined method `valid?'for nil: nilclass
- ruby on rails 6 - [error] nomethoderror in followscontroller # create undefined method `follows' for nil: nilclass
- ruby on rails 6 - [error] nomethoderror in communities # index undefined method `following?'for nil: nilclass
- i want to solve an error on the ruby on rails ec site nomethoderror in cartscontroller # add_item
- ruby on rails - about nomethoderror in skilscontroller # create
- ruby on rails - cart function routing error cannot be resolved
- ruby on rails - rails s can't
- ruby on rails - how to transition from the top page
- python - you may need to restart the kernel to use updated packages error
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- python 3x - typeerror: 'method' object is not subscriptable
- i want to call a child component method from a parent in vuejs
- dart - flutter: the instance member'stars' can't be accessed in an initializer error
- xcode - pod install [!] no `podfile 'found in the project directory