Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #7019

Where is the good place for adding custom datas when sending form (insert/update)

From jacki <collector@idealan.pl>
Newsgroups comp.lang.ruby
Subject Where is the good place for adding custom datas when sending form (insert/update)
Date 2014-09-03 10:58 +0200
Organization ATMAN - ATM S.A.
Message-ID <lu6l7f$b61$1@node2.news.atman.pl> (permalink)

Show all headers | View raw


Hi,

I'm new to rails. I'm learning and don't always know if i'm doing right.
So, let's assume that i that have table in the database:
table X:
field1
field2
custom_field

i've done
# rails g scaffold X field1:somethin field2:something custom_field:something

I've deleted a custom_field entries from _form.html.erb because i need
to fill this field depending on the field1. So i need to check what have
been sent in field1 and based on that fill the custom_field.

Ok, so i think i need to do this in the controller, but i do not fully
understand where.

x.update(x_params)

so do i need to modyfy x_params method whitch looks like:

def x_params
      params.require(:x).permit(:field1, :field2)
end

i'm so confused :)

Back to comp.lang.ruby | Previous | NextNext in thread | Find similar


Thread

Where is the good place for adding custom datas when sending form (insert/update) jacki <collector@idealan.pl> - 2014-09-03 10:58 +0200
  Re: Where is the good place for adding custom datas when sending form   (insert/update) Robert Klemme <shortcutter@googlemail.com> - 2014-09-03 19:50 +0200

csiph-web