Re: [Rails] additional params in controller create action

24 views
Skip to first unread message

Colin Law

unread,
Apr 26, 2017, 3:25:53 AM4/26/17
to Ruby on Rails: Talk
On 26 April 2017 at 02:04, fugee ohu <fuge...@gmail.com> wrote:
> I'm trying to assign additional parameters to create to satisfy validations
> in the model like so
> address="params[:address0] + params[:address1]
> @user.address=address
> if @user.save
> ...
> In this example there's address0 and address1 in the form but not the schema
> which has only :address
> Should this work?

Try it and see. If it does not then debug it to find why.

Colin

fugee ohu

unread,
Apr 26, 2017, 9:02:05 AM4/26/17
to Ruby on Rails: Talk
Same select rolls back and then succeeds after render  in the case of save didn't succeed Other than this I'm clueless

  User Load (28.2ms)  SELECT  `users`.* FROM `users` WHERE `users`.`id` = 2 ORDER BY `users`.`id` ASC LIMIT 1
  Artist Load (4.6ms)  SELECT  `artists`.* FROM `artists` WHERE `artists`.`id` = 14 LIMIT 1
   (0.9ms)  BEGIN
   (3.7ms)  ROLLBACK
  Rendering user/press_releases/_form.html.erb within layouts/application
  Artist Load (2.6ms)  SELECT  `artists`.* FROM `artists` WHERE `artists`.`id` = 14 LIMIT 1

Colin Law

unread,
Apr 26, 2017, 9:10:24 AM4/26/17
to Ruby on Rails: Talk
Did your debugging show that @user.address is setup correctly?

Colin

>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/344f6bbb-0cff-4539-89d7-dadd0d77e548%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages